Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 54 additions & 38 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ toc::[]
|===
| Aspect | Status

| Directory creation | Working
| Shell detection | Stub (returns hardcoded list)
| Config backup | Not implemented
| Source injection | Not implemented
| Directory creation | Working
| Shell detection | ✓ Working (checks /usr/bin, /bin, /usr/local/bin, /opt/homebrew/bin)
| Config backup | ✓ Working (timestamped backups before modification)
| Source injection | ✓ Working (shell-specific syntax for all 10 shells)
|===

*This is alpha software.* The core architecture is complete, but the primary feature (modularising shell configs) is not yet functional. See <<Development Status>> for details.
*Version 0.1* - Core functionality complete. The tool detects installed shells, backs up configs, and injects modular sourcing blocks.

=== What You Get

Expand Down Expand Up @@ -175,7 +175,7 @@ nix profile install github:hyperpolymath/modshells

== Usage

=== Current Functionality (v0.0)
=== Basic Usage

[source,bash]
----
Expand All @@ -184,23 +184,42 @@ gprbuild -p -j0 modshells.gpr
./bin/modshells
----

Output:
Example output:
[source]
----
Starting modshells initialisation...
=== Modshells v0.1 ===
Configuration path: /home/user/.config/nushell/modshells
Modular directories created idempotently.
----

This creates the directory structure. Shell detection and config injection are not yet functional.
Creating modular directory structure...
Directories ready: core, tools, misc, os, ui

Detecting installed shells...
bash: [installed]
dash: [not found]
fish: [installed]
ion: [not found]
nushell: [installed]
tcsh: [not found]
zsh: [installed]
oils: [not found]
pwsh: [not found]
ksh: [not found]

Modularising shell configurations...
Modularising bash...
Backup created: /home/user/.bashrc.modshells-backup-20250101-120000
Injected modshells sourcing block.
Modularising fish...
Injected modshells sourcing block.
...

=== Modshells complete ===
----

=== Planned Functionality (v0.1+)
=== Custom Configuration Path

[source,bash]
----
# Initialise modular structure and inject into all detected shells
modshells

# Use custom configuration path
export MODSHELLS_CONFIG_PATH="$HOME/.config/shells/modular"
modshells
Expand Down Expand Up @@ -262,9 +281,9 @@ core/

== Development Status

Current version: **v0.0 (Alpha)**
Current version: **v0.1**

=== Working Now
=== Implemented Features

[cols="1,2"]
|===
Expand All @@ -276,36 +295,33 @@ Current version: **v0.0 (Alpha)**
| Path resolution
| Reads `MODSHELLS_CONFIG_PATH` or defaults to `~/.config/nushell/modshells`

| Shell enumeration
| Defines 10 shell types (Bash, Zsh, Fish, Nushell, Ion, Oils, Tcsh, Ksh, Dash, PowerShell)

| Build system
| GPRBuild project files with CI/CD (GitHub Actions)

| Idempotency markers
| Signature-based detection to prevent duplicate injections
|===

=== Not Yet Implemented (Stubs)

[cols="1,2"]
|===
| Feature | Current State

| Shell detection
| Returns hardcoded list (Nushell, Bash, Zsh); needs `which`/`command -v` checks
| Checks `/usr/bin`, `/bin`, `/usr/local/bin`, `/opt/homebrew/bin` for shell binaries

| Config file backup
| Not implemented; required before modifying dotfiles
| Creates timestamped backups (`.modshells-backup-YYYYMMDD-HHMMSS`) before modification

| Source injection
| Not implemented; the core feature that modifies `.bashrc`, `.zshrc`, etc.
| Appends shell-specific sourcing blocks with `MODSHELLS_START`/`END` markers

| Shell-specific syntax
| Not implemented; each shell needs different sourcing syntax
| Generates correct sourcing code for all 10 shells (POSIX, Fish, Nushell, Tcsh, Ion, PowerShell)

| Idempotency
| Signature-based detection prevents duplicate injections

| Build system
| GPRBuild project files with CI/CD (GitHub Actions)
|===

See link:ROADMAP.adoc[ROADMAP.adoc] for the complete development plan.
=== Future Enhancements

See link:ROADMAP.adoc[ROADMAP.adoc] for planned features including:

* Command-line arguments (`--shell=bash,zsh`, `--dry-run`)
* Shell-agnostic `.modshells` config format
* Configuration drift detection
* Snippet management commands

== Contributing

Expand Down
55 changes: 37 additions & 18 deletions src/main/modshells.adb
Original file line number Diff line number Diff line change
@@ -1,31 +1,50 @@
-- src/main/modshells.adb
-- SPDX-License-Identifier: AGPL-3.0-or-later OR MIT
with Shell_Manager;
with Config_Store;
with Ada.Text_IO;

procedure Modshells is

Config_Path : constant String := Config_Store.Get_Modshell_Root_Path;
Shells : Shell_Manager.Shell_List := Shell_Manager.Detect_Shells;

begin
Ada.Text_IO.Put_Line("Starting modshells initialisation...");
Ada.Text_IO.Put_Line("Configuration path: " & Config_Path);

-- Idempotent creation of directories (core, tools, misc, os, ui)
Shell_Manager.Create_Modshell_Directories(
Root_Path => Config_Path
);

Ada.Text_IO.Put_Line("Modular directories created idempotently.");

-- [Continue with application logic, such as shell detection, etc.]

exception
when others =>
Ada.Text_IO.Put_Line ("=== Modshells v0.1 ===");
Ada.Text_IO.Put_Line ("Configuration path: " & Config_Path);
Ada.Text_IO.New_Line;

-- Step 1: Idempotent creation of directories (core, tools, misc, os, ui)
Ada.Text_IO.Put_Line ("Creating modular directory structure...");
Shell_Manager.Create_Modshell_Directories (Root_Path => Config_Path);
Ada.Text_IO.Put_Line (" Directories ready: core, tools, misc, os, ui");
Ada.Text_IO.New_Line;

-- Step 2: Detect installed shells
Ada.Text_IO.Put_Line ("Detecting installed shells...");
for I in Shells'Range loop
declare
Error_Msg : constant String :=
"FATAL ERROR: Modshells failed during initial setup.";
Status_Str : constant String :=
(if Shells (I).Status = Shell_Manager.Installed then "[installed]"
else "[not found]");
begin
Ada.Text_IO.Put_Line(Error_Msg);
raise;
Ada.Text_IO.Put_Line (" " & Shell_Manager.To_String (Shells (I).Name) &
": " & Status_Str);
end;
end loop;
Ada.Text_IO.New_Line;

-- Step 3: Modularise all installed shells
Ada.Text_IO.Put_Line ("Modularising shell configurations...");
Shell_Manager.Modularise_All_Shells (Modshells_Path => Config_Path);
Ada.Text_IO.New_Line;

Ada.Text_IO.Put_Line ("=== Modshells complete ===");
Ada.Text_IO.Put_Line ("Add configuration snippets to the modular directories.");
Ada.Text_IO.Put_Line ("Files are sourced alphabetically (use numeric prefixes for ordering).");

exception
when others =>
Ada.Text_IO.Put_Line ("FATAL ERROR: Modshells failed during setup.");
raise;
end Modshells;
Loading
Loading