Skip to content

Commit

Permalink
Leave only needed instances
Browse files Browse the repository at this point in the history
  • Loading branch information
mosteo committed Mar 24, 2023
1 parent 8abeff9 commit c758f80
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 30 deletions.
24 changes: 4 additions & 20 deletions src/alire/alire-config-edit.adb
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ with Alire.Platforms.Folders;
with Alire.Platforms.Current;
with Alire.Utils;

with CLIC.Config.Edit.Typed;
with CLIC.Config.Edit;
with CLIC.Config.Load;

package body Alire.Config.Edit is

use Ada.Strings.Unbounded;
use AAA.Strings;
use TOML;
package Typed renames CLIC.Config.Edit.Typed;

type String_Access is access String;
Config_Path : String_Access;
Expand Down Expand Up @@ -77,30 +76,15 @@ package body Alire.Config.Edit is
Value : Boolean;
Check : CLIC.Config.Check_Import := null)
is

function Set_Boolean_Impl is new CLIC.Config.Edit.Set_Typed
(Boolean, TOML_Boolean, Boolean'Image);
begin
Assert (Typed.Set_Boolean (Filepath (Level), Key, Value, Check),
Assert (Set_Boolean_Impl (Filepath (Level), Key, Value, Check),
"Cannot set config key '" & Key & "' at level " & Level'Image);
-- Reload after change
Load_Config;
end Set_Boolean;

-----------------
-- Set_Integer --
-----------------

procedure Set_Integer (Level : Config.Level;
Key : CLIC.Config.Config_Key;
Value : Integer;
Check : CLIC.Config.Check_Import := null)
is
begin
Assert (Typed.Set_Integer (Filepath (Level), Key, Value, Check),
"Cannot set config key '" & Key & "' at level " & Level'Image);
-- Reload after change
Load_Config;
end Set_Integer;

--------------
-- Filepath --
--------------
Expand Down
5 changes: 0 additions & 5 deletions src/alire/alire-config-edit.ads
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ package Alire.Config.Edit is
Value : Boolean;
Check : CLIC.Config.Check_Import := null);

procedure Set_Integer (Level : Config.Level;
Key : CLIC.Config.Config_Key;
Value : Integer;
Check : CLIC.Config.Check_Import := null);

-- To ease the pain with circularities in old GNAT versions, we have also
-- here all non-preelaborable things related to config loading. This
-- way, querying stays preelaborable.
Expand Down
4 changes: 0 additions & 4 deletions src/alire/alire-selftest.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ package body Alire.Selftest is
Config.Edit.Set_Globally (Key, "777");
pragma Assert (Integer (Config.DB.Get (Key, 0)) = 777);

-- Typed storing of integer
Config.Edit.Set_Integer (Config.Global, Key, 888);
pragma Assert (Integer (Config.DB.Get (Key, 0)) = 888);

-- Raw storing of boolean
Config.Edit.Set_Globally (Key, "true");
pragma Assert (Config.DB.Get (Key, False) = True);
Expand Down

0 comments on commit c758f80

Please sign in to comment.