Skip to content

Commit ab96837

Browse files
author
Jonathan D.A. Jewell
committed
WIP: Save progress before infrastructure sync
Auto-committed by infrastructure fix script to preserve work in progress.
1 parent 05d506b commit ab96837

9 files changed

Lines changed: 310 additions & 72 deletions

File tree

default.cgpr

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
-- This gpr configuration file was generated by gprconfig
2+
-- using this command line:
3+
-- gprconfig --config=default
4+
-- from /var/home/hyper/workspace/projects/to-git/_tools/modshells/
5+
configuration project Default is
6+
for Target use "x86_64-linux";
7+
for Canonical_Target use "x86_64-linux";
8+
for Inherit_Source_Path ("C++") use ("C");
9+
for Inherit_Source_Path ("Asm_Cpp") use ("Asm");
10+
for Default_Language use "Ada";
11+
for Archive_Builder use ("ar", "cr");
12+
for Archive_Builder_Append_Option use ("q");
13+
for Archive_Indexer use ("ranlib");
14+
for Archive_Suffix use ".a";
15+
for Symbolic_Link_Supported use "true";
16+
for Library_Major_Minor_Id_Supported use "true";
17+
18+
package Compiler is
19+
for Language_Kind ("ada") use "unit_based";
20+
end Compiler;
21+
22+
package Naming is
23+
for Spec_Suffix ("Ada") use ".ads";
24+
for Body_Suffix ("Ada") use ".adb";
25+
26+
for Body_Suffix ("Asm") use ".s";
27+
for Body_Suffix ("Asm2") use ".asm";
28+
for Body_Suffix ("Asm_Cpp") use ".S";
29+
30+
for Body_Suffix ("C") use ".c";
31+
for Spec_Suffix ("C") use ".h";
32+
33+
for Spec_Suffix ("C++") use ".hh";
34+
for Body_Suffix ("C++") use ".cpp";
35+
36+
for Body_Suffix ("Fortran") use ".f";
37+
38+
for Body_Suffix ("Rust") use ".rs";
39+
40+
for Casing use "lowercase";
41+
for Dot_Replacement use "-";
42+
end Naming;
43+
44+
package Binder is
45+
for Bindfile_Option_Substitution ("-static") use ("-static-libgcc");
46+
for Bindfile_Option_Substitution ("-shared") use ("-shared-libgcc");
47+
end Binder;
48+
49+
package Clean is
50+
for Source_Artifact_Extensions ("Ada") use (".dg", ".rep");
51+
for Object_Artifact_Extensions ("Ada") use (".s", ".ci", ".gcno", ".su");
52+
53+
for Source_Artifact_Extensions ("C") use (".gli");
54+
for Object_Artifact_Extensions ("C") use (".s", "ci", ".gcno", ".su");
55+
56+
for Source_Artifact_Extensions ("C++") use (".gli");
57+
for Object_Artifact_Extensions ("C++") use (".s", "ci", ".gcno", ".su");
58+
-- Remove the files generated by gnatinspect (in the context of GPS)
59+
for Artifacts_In_Object_Dir use Clean'Artifacts_In_Object_Dir
60+
& ("gnatinspect.*");
61+
end Clean;
62+
end Default;

hello.adb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
with Ada.Text_IO; use Ada.Text_IO;
2+
procedure Hello is
3+
begin
4+
Put_Line("Hello, world!");
5+
end Hello;

modshells.gpr

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
-- GNAT Project File for Modular Shells Utility
1+
-- File: modshells.gpr
2+
-- GNAT Project File for the modshells application.
23
project Modshells is
3-
4-
for Source_Dirs use ("src/main", "src/config_store", "src/shell_manager", "src/utils");
4+
-- Point to the correct main file
5+
for Main use ("src/shell_manager/shell_manager.adb");
6+
-- Include all source directories
7+
for Source_Dirs use ("src/**");
8+
-- Object and executable directories
59
for Object_Dir use "obj";
610
for Exec_Dir use "bin";
7-
for Main use ("modshells.adb");
8-
9-
-- Define LMDB as a required external library
10-
package Linker is
11-
-- Requires LMDB library to be installed or compiled in vendor/
12-
for Linker_Options use ("-lrt", "-lMDB", "-pthread");
13-
end Linker;
14-
15-
-- Define compiler switches for high quality/safety (Rhodium Standard)
16-
package Compiler is
17-
-- -gnatwa: All warnings on, warnings as errors
18-
-- -gnatya: Check style, naming conventions, etc.
19-
-- -fstack-check: Enhance security with stack overflow detection
20-
for Default_Switches ("ada") use ("-gnatws", "-gnatV", "-gnatyabcefhiklprnsu", "-gnata", "-fstack-check");
21-
end Compiler;
22-
11+
-- Optional: Parallel build
12+
package Builder is
13+
for Default_Switches ("ada") use ("-j4");
14+
end Builder;
2315
end Modshells;

raise

Whitespace-only changes.

return

Whitespace-only changes.

src/config_store/config_store.adb

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,46 +2,50 @@ with Ada.Environment_Variables;
22
with Ada.Strings.Unbounded;
33
with Ada.Directories;
44
with Ada.Text_IO;
5+
with Ada.IO_Exceptions;
56

67
package body Config_Store is
78

8-
use Ada.Environment_Variables;
9-
use Ada.Strings.Unbounded;
9+
-- Fix: Use clause needed for String_Access operations (like != null)
10+
use Ada.Strings.Unbounded;
1011

1112
ENV_VAR_NAME : constant String := "MODSHELLS_CONFIG_PATH";
1213

14+
----------------------------------------------------------------------
15+
-- Helper function to get the current user's home directory robustly.
16+
----------------------------------------------------------------------
1317
function Get_Home_Directory return String is
18+
-- FIX: Must explicitly use the fully qualified access type
19+
Home_Path_Ptr : constant Ada.Strings.Unbounded.String_Access := Ada.Environment_Variables.Value("HOME");
1420
begin
15-
declare
16-
Home_Path_Ptr : constant String_Access := Value("HOME");
17-
begin
18-
if Home_Path_Ptr /= null then
19-
return Home_Path_Ptr.all;
20-
else
21-
return Ada.Directories.Current_Directory;
22-
end if;
23-
exception
24-
when Name_Error =>
25-
return Ada.Directories.Current_Directory;
26-
when others =>
27-
raise;
28-
end;
21+
if Home_Path_Ptr /= null then
22+
return Home_Path_Ptr.all;
23+
else
24+
return Ada.Directories.Current_Directory;
25+
end if;
26+
exception
27+
when Ada.IO_Exceptions.Name_Error =>
28+
return Ada.Directories.Current_Directory;
29+
when others =>
30+
raise;
2931
end Get_Home_Directory;
3032

33+
-- The default path for Nushell configuration on Linux/Kinoite
34+
-- FIX: Use fully qualified Separator
3135
DEFAULT_ROOT_PATH : constant String :=
3236
Get_Home_Directory & Ada.Directories.Separator & ".config/nushell/modshells";
3337

38+
----------------------------------------------------------------------
39+
-- Implements the robust retrieval of the modular shell root path.
40+
----------------------------------------------------------------------
3441
function Get_Modshell_Root_Path return String is
3542
Path_Value : String := "";
36-
Env_Value_Ptr : String_Access;
43+
-- FIX: Must explicitly use the fully qualified access type
44+
Env_Value_Ptr : constant Ada.Strings.Unbounded.String_Access := Ada.Environment_Variables.Value(ENV_VAR_NAME);
3745
begin
38-
-- 1. Check for the environment variable (Accessibility & Interoperability)
39-
Env_Value_Ptr := Value(ENV_VAR_NAME);
40-
4146
if Env_Value_Ptr /= null then
4247
Path_Value := Env_Value_Ptr.all;
4348
else
44-
-- 2. Fall back to the calculated default path (Dependability)
4549
Path_Value := DEFAULT_ROOT_PATH;
4650
end if;
4751

@@ -53,6 +57,4 @@ package body Config_Store is
5357
raise;
5458
end Get_Modshell_Root_Path;
5559

56-
-- ... Placeholder for other functions in Config_Store package body ...
57-
58-
end Config_Store;
60+
end Config_Store;
Lines changed: 139 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,139 @@
1-
-- File: modshells/src/main/modshells.adb
2-
3-
with Shell_Manager; -- 1. Import the package
4-
-- ... other necessary packages (e.g., Ada.Strings.Unbounded) ...
5-
6-
procedure Modshells is
7-
8-
-- NOTE: This path would ideally be derived from environment variables
9-
-- or configuration settings managed by your config_store package.
10-
-- For this example, we use a placeholder path:
11-
Modshell_Root_Path : constant String :=
12-
"~/.config/nushell/modshells";
13-
14-
begin
15-
-- [Application Initialisation Logic]
16-
17-
-- 2. Call the new idempotent directory creation function.
18-
Shell_Manager.Create_Modshell_Directories(
19-
Root_Path => Modshell_Root_Path
20-
);
21-
22-
-- [Rest of the application logic]
23-
24-
exception
25-
when others =>
26-
-- Implement robust error handling (Dependability priority)
27-
-- perhaps using your config_store or logging utilities here.
28-
raise;
29-
end Modshells;
1+
with Ada.Directories;
2+
with Ada.Text_IO;
3+
with Ada.IO_Exceptions;
4+
with Ada.Strings.Unbounded;
5+
with Config_Store;
6+
with Shell_Manager;
7+
8+
-- Assuming shell_manager.ads defines Shell_Type, Shell_Status, Shell_Info, and Shell_List
9+
package body Shell_Manager is
10+
11+
-- FIX: Ensure Ada.Directories is in the use clause for Separator visibility.
12+
-- Use clauses for visibility
13+
use Ada.Directories, Ada.Strings.Unbounded, Ada.Text_IO;
14+
15+
-- Constant signature for Is_Modularized check
16+
MODULARIZED_SIGNATURE : constant String := "# MODSHELLS_START - DO NOT REMOVE THIS LINE";
17+
18+
-- FIX: Type must be constrained OR bounds must be given immediately.
19+
-- We define a generic type and rely on the constant definition to constrain it.
20+
type Directory_List_Type is array (Positive range <>) of String;
21+
Required_Subdirectories : constant Directory_List_Type :=
22+
("core", "tools", "misc", "os", "ui");
23+
24+
----------------------------------------------------------------------
25+
-- Helper function to join two path components correctly.
26+
----------------------------------------------------------------------
27+
function Join_Path (Base : in String; Name : in String) return String is
28+
Path_Separator : constant Character := Separator; -- Separator is now visible
29+
begin
30+
if Base'Length > 0 and then Base(Base'Last) /= Path_Separator then
31+
return Base & Path_Separator & Name;
32+
else
33+
return Base & Name;
34+
end if;
35+
end Join_Path;
36+
37+
----------------------------------------------------------------------
38+
-- Idempotently creates the modular shell directories.
39+
----------------------------------------------------------------------
40+
procedure Create_Modshell_Directories (Root_Path : in String) is
41+
begin
42+
if not Exists(Root_Path) then
43+
begin
44+
Create_Directory(Root_Path);
45+
exception
46+
-- FIX: Qualify ambiguous exceptions
47+
when Ada.Directories.Name_Error | Ada.Directories.Use_Error => raise;
48+
end;
49+
end if;
50+
51+
for Subdir_Name of Required_Subdirectories loop
52+
declare
53+
Full_Path : constant String := Join_Path(Root_Path, Subdir_Name);
54+
begin
55+
if not Exists(Full_Path) then
56+
Create_Directory(Full_Path);
57+
end if;
58+
exception
59+
-- FIX: Qualify ambiguous exceptions
60+
when Ada.Directories.Name_Error | Ada.Directories.Use_Error => raise;
61+
end;
62+
end loop;
63+
end Create_Modshell_Directories;
64+
65+
----------------------------------------------------------------------
66+
-- Shell Detection Stub (v0.0 Alpha)
67+
----------------------------------------------------------------------
68+
function Detect_Shells return Shell_List is
69+
-- Assumes Shell_List is an unconstrained type defined in .ads.
70+
-- FIX: MUST constrain the array instance here.
71+
Shell_Array : Shell_List(1..3);
72+
begin
73+
Shell_Array(1).Name := Nushell;
74+
Shell_Array(1).Status := Installed;
75+
Shell_Array(2).Name := Bash;
76+
Shell_Array(2).Status := Installed;
77+
Shell_Array(3).Name := Zsh;
78+
Shell_Array(3).Status := Installed;
79+
return Shell_Array;
80+
end Detect_Shells;
81+
82+
----------------------------------------------------------------------
83+
-- Converts Shell_Type enumeration to String.
84+
----------------------------------------------------------------------
85+
function To_String(Shell : Shell_Type) return String is
86+
begin
87+
case Shell is
88+
when Bash => return "bash";
89+
when Dash => return "dash";
90+
when Fish => return "fish";
91+
when Ion => return "ion";
92+
when Nushell => return "nushell";
93+
when Tcsh => return "tcsh";
94+
when Zsh => return "zsh";
95+
when Oils => return "oils";
96+
when Pwsh => return "pwsh";
97+
when Ksh => return "ksh";
98+
end case;
99+
end To_String;
100+
101+
----------------------------------------------------------------------
102+
-- Idempotency Check (Checks if the config file already sources the structure).
103+
----------------------------------------------------------------------
104+
function Is_Modularized (Shell : Shell_Type) return Boolean is
105+
Config_File_Path : constant String := "/tmp/mock_config.txt";
106+
File_Handle : File_Type;
107+
Line : String;
108+
Last : Natural;
109+
begin
110+
begin
111+
Open(File_Handle, In_File, Config_File_Path);
112+
exception
113+
-- FIX: Explicitly qualify Name_Error to resolve hiding ambiguity
114+
when Ada.IO_Exceptions.Name_Error => return False;
115+
when others => raise;
116+
end;
117+
118+
while not End_Of_File(File_Handle) loop
119+
Get_Line(File_Handle, Line, Last);
120+
if Line(1..Last) = MODULARIZED_SIGNATURE(1..Last) then
121+
Close(File_Handle);
122+
return True;
123+
end if;
124+
end loop;
125+
126+
Close(File_Handle);
127+
return False;
128+
end Is_Modularized;
129+
130+
----------------------------------------------------------------------
131+
-- MISSING BODY FIX: Placeholder for Modularise_Config
132+
----------------------------------------------------------------------
133+
procedure Modularise_Config(Shell : Shell_Type) is
134+
-- Stub to satisfy the package specification
135+
begin
136+
-- The only statement:
137+
Ada.Text_IO.Put_Line("STUB: Modularising config for " & To_String(Shell));
138+
end Modularise_Config;
139+
end Shell_Manager;

test.gpr

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
project Test is
2+
for Languages use ("Ada");
3+
for Source_Dirs use (".");
4+
for Main use ("hello.adb");
5+
end Test;

0 commit comments

Comments
 (0)