-
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
6 changed files
with
77 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let some_variable = "some value'" | ||
in { | ||
some_string = some_variable, | ||
some_record = { | ||
some_string = some_variable, | ||
some_naturals = [1,2,3], | ||
some_doubles = [1.2, 2.3], | ||
some_strings = ["value1", "value2"], | ||
some_nil = None | ||
} | ||
} |
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,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dotcrypt::Cli::Commands::ENV | ||
def self.included(thor) | ||
thor.class_eval do | ||
include Dotcrypt::Cli::Commands::Globals | ||
|
||
desc "env", "prints exports for ennv" | ||
|
||
def env = Dotcrypt::Cli::Commands::Show::Handler.new(**options.merge(output: :env)).call | ||
end | ||
end | ||
end |
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,33 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dotcrypt::Cli::Commands::Exec | ||
def self.included(thor) | ||
thor.class_eval do | ||
include Dotcrypt::Cli::Commands::Globals | ||
|
||
desc "exec COMMAND", "exec command a command with dhall env" | ||
|
||
def exec(*command) = Handler.new(command, **options).call | ||
end | ||
end | ||
|
||
class Handler | ||
def initialize(command, **options) | ||
@command = command | ||
@options = options | ||
end | ||
|
||
def call | ||
exec(env, *@command) | ||
end | ||
|
||
private | ||
|
||
def env | ||
@env ||= Dotcrypt::Dhall.load_from(@options[:file]).then do |c| | ||
# TODO: validate variable names | ||
Dotcrypt::Flattener.call(c, separator: @options[:separator]) | ||
end | ||
end | ||
end | ||
end |
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,17 @@ | ||
# frozen_string_literal: true | ||
|
||
module Dotcrypt::Cli::Commands::Globals | ||
def self.included(thor) | ||
thor.class_eval do | ||
option :separator, aliases: :s, | ||
type: :string, | ||
default: "_", | ||
desc: "Separator for flattening" | ||
|
||
option :file, aliases: :f, | ||
type: :string, | ||
default: ".env.dhall", | ||
desc: "Dhall file to read." | ||
end | ||
end | ||
end |
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