Class: Sshify::Commands::Config
- Inherits:
-
Sshify::Command
- Object
- Sshify::Command
- Sshify::Commands::Config
- Defined in:
- lib/sshify/commands/config.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
-
#initialize(options) ⇒ Config
constructor
A new instance of Config.
Methods inherited from Sshify::Command
#command, #cursor, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which
Constructor Details
#initialize(options) ⇒ Config
Returns a new instance of Config.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/sshify/commands/config.rb', line 11 def initialize() @options = @config = TTY::Config.new @config.filename = "sshify-config" @config.extname = ".yml" @config.append_path Dir.home @cmd = TTY::Command.new end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sshify/commands/config.rb', line 22 def execute(input: $stdin, output: $stdout) @config ||= self.class.new(@options).config @config.read if @config.persisted? selection = prompt.select("Select one") do || .choice "See config" .choice "Create new config" .choice "Add new server" .choice "Remove server" end case selection when "See config" watch_config(output) when "Create new config" create_config when "Add new server" add_server when "Remove server" remove_server(output) end end |