Class: DuniterRbCli::Commands::Config::Network
- Inherits:
-
DuniterRbCli::Command
- Object
- DuniterRbCli::Command
- DuniterRbCli::Commands::Config::Network
- Defined in:
- lib/duniter_rb_cli/commands/config/network.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Network
constructor
A new instance of Network.
Methods inherited from DuniterRbCli::Command
#command, #config, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(options) ⇒ Network
Returns a new instance of Network.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/duniter_rb_cli/commands/config/network.rb', line 9 def initialize() @options = @config = config @config.filename = 'network' @config.extname = '.yml' @config.append_path Dir.pwd @config.append_path Dir.home @config.read if @config.exist? @actual_config = @config.fetch(:name) end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/duniter_rb_cli/commands/config/network.rb', line 20 def execute(input: $stdin, output: $stdout) output.puts "Config value: #{@actual_config}" unless @actual_config.nil? user_response = prompt.select("Set G1 or G1-test:", %w(G1-test G1)) @config.set :name, value: user_response user_response == "G1" ? @config.set(:base_url, value: "https://g1.duniter.org/") : @config.set(:base_url, value: "https://g1-test.duniter.org/") @config.write(force: true) output.puts "Value successfully set to: #{@config.fetch(:name)}" output.puts "Base url: #{@config.fetch(:base_url)}" end |