forked from alire-project/alire
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
285 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package Alire.Config.Builtins is | ||
|
||
subtype Builtin is Builtin_Option; | ||
|
||
-------------- | ||
-- Builtins -- | ||
-------------- | ||
|
||
Dependencies_Shared : constant Builtin := New_Builtin | ||
(Key => "dependencies.shared", | ||
Def => False, | ||
Help => | ||
"When true, dependencies are downloaded and built in a shared " | ||
& "location inside the global cache. When false (default), " | ||
& "dependencies are sandboxed in each workspace."); | ||
|
||
Index_Auto_Community : constant Builtin := New_Builtin | ||
(Key => "index.auto_community", | ||
Def => True, | ||
Help => | ||
"When unset or true, the community index will be added " & | ||
"automatically when required if no other index is configured."); | ||
|
||
Solver_Autonarrow : constant Builtin := New_Builtin | ||
(Key => "solver.autonarrow", | ||
Def => True, | ||
Help => | ||
"If true, `alr with` will replace 'any' dependencies with the" | ||
& " appropriate caret/tilde dependency."); | ||
|
||
end Alire.Config.Builtins; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
with Alire.Config.Edit; | ||
|
||
package body Alire.Config is | ||
|
||
--------- | ||
-- Get -- | ||
--------- | ||
|
||
function Get (This : Builtin_Option) return String | ||
is (DB.Get (+This.Key, +This.Def)); | ||
|
||
--------- | ||
-- Get -- | ||
--------- | ||
|
||
function Get (This : Builtin_Option) return Boolean | ||
is (DB.Get (+This.Key, Boolean'Value (+This.Def))); | ||
|
||
----------------- | ||
-- Set_Locally -- | ||
----------------- | ||
|
||
procedure Set_Locally (This : Builtin_Option; Value : String) is | ||
begin | ||
Edit.Set_Locally (+This.Key, Value, This.Check); | ||
end Set_Locally; | ||
|
||
------------------ | ||
-- Set_Globally -- | ||
------------------ | ||
|
||
procedure Set_Globally (This : Builtin_Option; Value : String) is | ||
begin | ||
Edit.Set_Globally (+This.Key, Value, This.Check); | ||
end Set_Globally; | ||
|
||
--------- | ||
-- Set -- | ||
--------- | ||
|
||
procedure Set (This : Builtin_Option; | ||
Level : Config.Level; | ||
Value : String) | ||
is | ||
begin | ||
Edit.Set (Level, +This.Key, Value, This.Check); | ||
end Set; | ||
|
||
--------- | ||
-- Set -- | ||
--------- | ||
|
||
procedure Set (This : Builtin_Option; | ||
Level : Config.Level; | ||
Value : Boolean) | ||
is | ||
begin | ||
Edit.Set_Boolean (Level, +This.Key, Value); | ||
end Set; | ||
|
||
----------- | ||
-- Unset -- | ||
----------- | ||
|
||
procedure Unset (This : Builtin_Option; | ||
Level : Config.Level) | ||
is | ||
begin | ||
Edit.Unset (Level, +This.Key); | ||
end Unset; | ||
|
||
----------- | ||
-- Image -- | ||
----------- | ||
|
||
function Image (Kind : Builtin_Kind) return String | ||
is (case Kind is | ||
when Cfg_Int => "Integer", | ||
when Cfg_Float => "Float", | ||
when Cfg_Bool => "Boolean", | ||
when Cfg_String => "String", | ||
when Cfg_Absolute_Path => "Absolute path", | ||
when Cfg_Existing_Absolute_Path => "Absolute path already existing", | ||
when Cfg_Email => "Email address", | ||
when Cfg_GitHub_Login => "GitHub login"); | ||
|
||
---------------- | ||
-- Is_Builtin -- | ||
---------------- | ||
|
||
function Is_Builtin (Key : CLIC.Config.Config_Key) return Boolean | ||
is (All_Builtins.Contains (Key)); | ||
|
||
--------------------- | ||
-- Kind_Of_Builtin -- | ||
--------------------- | ||
|
||
function Kind_Of_Builtin (Key : CLIC.Config.Config_Key) | ||
return Builtin_Kind | ||
is | ||
begin | ||
if All_Builtins.Contains (Key) then | ||
return All_Builtins (Key).Kind; | ||
end if; | ||
|
||
Raise_Checked_Error ("Kind is only valid for builtin config key"); | ||
end Kind_Of_Builtin; | ||
|
||
----------------- | ||
-- New_Builtin -- | ||
----------------- | ||
|
||
function New_Builtin (Key : CLIC.Config.Config_Key; | ||
Kind : Builtin_Kind; | ||
Def : String; | ||
Help : String; | ||
Check : CLIC.Config.Check_Import := null) | ||
return Builtin_Option | ||
is | ||
begin | ||
return Result : constant Builtin_Option := (Key => +Key, | ||
Kind => Kind, | ||
Def => +Def, | ||
Help => +Help, | ||
Check => Check) | ||
do | ||
All_Builtins.Insert (Key, Result); | ||
end return; | ||
end New_Builtin; | ||
|
||
----------------- | ||
-- New_Builtin -- | ||
----------------- | ||
|
||
function New_Builtin (Key : CLIC.Config.Config_Key; | ||
Def : Boolean; | ||
Help : String; | ||
Check : CLIC.Config.Check_Import := null) | ||
return Builtin_Option | ||
is (New_Builtin (Key => Key, | ||
Kind => Cfg_Bool, | ||
Def => Def'Image, | ||
Help => Help, | ||
Check => Check)); | ||
|
||
end Alire.Config; |
Oops, something went wrong.