Skip to content

Commit

Permalink
implement -C/--chdir flag
Browse files Browse the repository at this point in the history
  • Loading branch information
atalii committed Oct 20, 2023
1 parent 8c2a380 commit 3ca33e4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/alr/alr-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ package body Alr.Commands is

Command_Line_Config_Path : aliased GNAT.OS_Lib.String_Access;

Command_Line_Chdir_Target_Path : aliased GNAT.OS_Lib.String_Access;

-- Following aliased booleans are used by GNAT.Command_Line processing:

Log_Quiet : Boolean renames Alire_Early_Elaboration.Switch_Q;
Expand Down Expand Up @@ -143,6 +145,11 @@ package body Alr.Commands is
"-c=", "--config=",
"Override configuration folder location");

Define_Switch (Config,
Command_Line_Chdir_Target_Path'Access,
"-C=", "--chdir=",
"Run Alire in the given directory");

Define_Switch (Config,
Alire.Force'Access,
"-f", "--force",
Expand Down Expand Up @@ -498,6 +505,14 @@ package body Alr.Commands is
end;
end if;

-- chdir(2) if necessary.

if Command_Line_Chdir_Target_Path /= null and then
Command_Line_Chdir_Target_Path.all /= ""
then
Ada.Directories.Set_Directory (Command_Line_Chdir_Target_Path.all);
end if;

Create_Alire_Folders;

begin
Expand Down

0 comments on commit 3ca33e4

Please sign in to comment.