Class: Kdep::Commands::Config
- Inherits:
-
Object
- Object
- Kdep::Commands::Config
- Defined in:
- lib/kdep/commands/config.rb
Overview
‘kdep config set <key> <value>` — writes a dotted key into ~/.kdep/config.yml. `kdep config get <key>` — reads a dotted key.
Currently used to seed Infisical settings:
kdep config set infisical.identity_id <uuid>
kdep config set infisical.host_api https://dev-env.leadfy.xyz/api
Constant Summary collapse
- SUBCOMMANDS =
%w[set get show].freeze
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(global_options:, command_options:, args:) ⇒ Config
constructor
A new instance of Config.
Constructor Details
Class Method Details
.option_parser ⇒ Object
14 15 16 17 18 |
# File 'lib/kdep/commands/config.rb', line 14 def self.option_parser OptionParser.new do |opts| opts. = "Usage: kdep config <set|get|show> [key] [value]" end end |
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/kdep/commands/config.rb', line 27 def execute sub = @args.shift unless SUBCOMMANDS.include?(sub) @ui.error("Unknown subcommand: #{sub.inspect}. Available: #{SUBCOMMANDS.join(', ')}") exit 2 end case sub when "set" key, value = @args[0], @args[1] unless key && value @ui.error("Usage: kdep config set <key> <value>") exit 2 end path = Kdep::UserConfig.set(key, value) @ui.success("Set #{key} -> #{value} (#{path})") when "get" key = @args[0] unless key @ui.error("Usage: kdep config get <key>") exit 2 end puts Kdep::UserConfig.get(*key.split(".")) when "show" puts Kdep::UserConfig.load.to_yaml end end |