Skip to content

Commit

Permalink
WIP: a few more
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Aug 23, 2023
1 parent 08db489 commit 0e79ece
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 30 deletions.
18 changes: 18 additions & 0 deletions src/alire/alire-config-builtins.ads
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,26 @@ package Alire.Config.Builtins is
-- not listed as a built-in. Each tool is a child of this key,
-- e.g.: toolchain.use.gnat, toolchain.use.gprbuild

-- UPDATE

Update_Manually_Only : constant Builtin := New_Builtin
(Key => "update.manually_only",
Def => False,
Help =>
"If true, Alire will not attempt to update dependencies even after "
& "the manifest is manually edited, or when no valid solution has "
& "been ever computed. All updates have to be manually requested "
& "through `alr update`");

-- WARNINGS

Warning_Caret : constant Builtin := New_Builtin
(Key => "warning.caret",
Def => True,
Help =>
"If true, Alire will warn about the use of caret (^) for pre-1 "
& "dependencies, for which tilde (~) is recommended instead.");

Warning_Old_Index : constant Builtin := New_Builtin
(Key => "warning.old_index",
Def => True,
Expand Down
14 changes: 1 addition & 13 deletions src/alire/alire-config-edit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,7 @@ package Alire.Config.Edit is
Cfg_String,
+("URL of the executable msys2 installer, " &
"e.g. 'https://github.com/msys2/msys2-installer/releases/" &
"download/2022-03-19/msys2-x86_64-20220319.exe'. (Windows only)")),

(+Keys.Update_Manually,
Cfg_Bool,
+("If true, Alire will not attempt to update dependencies even after "
& "the manifest is manually edited, or when no valid solution has "
& "been ever computed. All updates have to be manually requested "
& "through `alr update`")),

(+Keys.Warning_Caret,
Cfg_Bool,
+("If true, Alire will warn about the use of caret (^) "
& "for pre-1 dependencies."))
"download/2022-03-19/msys2-x86_64-20220319.exe'. (Windows only)"))

);

Expand Down
7 changes: 0 additions & 7 deletions src/alire/alire-config.ads
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,10 @@ package Alire.Config is

use CLIC.Config;

Update_Manually : constant Config_Key := "update-manually-only";
-- Used by `get --only` to flag a workspace to not autoupdate itself
-- despite having no solution in the lockfile.

User_Email : constant Config_Key := "user.email";
User_Name : constant Config_Key := "user.name";
User_Github_Login : constant Config_Key := "user.github_login";

Warning_Caret : constant Config_Key := "warning.caret";
-- Set to false to disable warnings about caret/tilde use for ^0 deps.

Msys2_Do_Not_Install : constant Config_Key := "msys2.do_not_install";
Msys2_Install_Dir : constant Config_Key := "msys2.install_dir";
Msys2_Installer : constant Config_Key := "msys2.installer";
Expand Down
6 changes: 3 additions & 3 deletions src/alire/alire-releases.adb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
with Ada.Directories;
with Ada.Text_IO;

with Alire.Config;
with Alire.Config.Builtins;
with Alire.Crates;
with Alire.Directories;
with Alire.Defaults;
Expand Down Expand Up @@ -85,7 +85,7 @@ package body Alire.Releases is
Newline : constant String := ASCII.LF & " ";
begin
for Dep of This.Flat_Dependencies loop
if Config.DB.Get (Config.Keys.Warning_Caret, Default => True)
if Config.Builtins.Warning_Caret.Get
and then
AAA.Strings.Contains (Dep.Versions.Image, "^0")
then
Expand All @@ -98,7 +98,7 @@ package body Alire.Releases is
& "The suspicious dependency is: " & TTY.Version (Dep.Image)
& Newline
& "You can disable this warning by setting the option "
& TTY.Emph (Config.Keys.Warning_Caret) & " to false.",
& TTY.Emph (Config.Builtins.Warning_Caret.Key) & " to false.",
Warnings.Caret_Or_Tilde);
return True;
end if;
Expand Down
8 changes: 3 additions & 5 deletions src/alr/alr-commands-get.adb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
with Ada.Directories;

with Alire.Config.Edit;
with Alire.Config.Builtins;
with Alire.Dependencies;
with Alire.Directories;
with Alire.Index;
Expand Down Expand Up @@ -161,10 +161,8 @@ package body Alr.Commands.Get is
Trace.Info ("Because --only was used, automatic dependency" &
" retrieval is disabled in this workspace:" &
" use `alr update` to apply dependency changes");
Alire.Config.Edit.Set_Boolean
(Alire.Config.Local,
Alire.Config.Keys.Update_Manually,
True);
Alire.Config.Builtins.Update_Manually_Only.Set (Alire.Config.Local,
True);

if not CLIC.User_Input.Not_Interactive then
Alire.Roots.Print_Nested_Crates (Cmd.Root.Path);
Expand Down
4 changes: 2 additions & 2 deletions src/alr/alr-commands.adb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ with CLIC.User_Input;

with Alire.Platforms;
with Alire_Early_Elaboration;
with Alire.Config.Builtins;
with Alire.Config.Edit;
with Alire.Errors;
with Alire.Index_On_Disk.Loading;
Expand Down Expand Up @@ -288,8 +289,7 @@ package body Alr.Commands is
Unchecked : Alire.Roots.Optional.Root renames Cmd.Optional_Root;

Manual_Only : constant Boolean :=
Alire.Config.DB.Get
(Alire.Config.Keys.Update_Manually, False);
Alire.Config.Builtins.Update_Manually_Only.Get;

package Conf renames Alire.Config;
begin
Expand Down

0 comments on commit 0e79ece

Please sign in to comment.