Class: Bartask::Cli
- Inherits:
-
Object
- Object
- Bartask::Cli
- Defined in:
- lib/bartask/cli.rb
Constant Summary collapse
- CMD =
"bartask"- USAGE =
"sub commands are:\n d : dump DB data\n r : restore DB data\nSee '\#{CMD} COMMAND --help' for more information on a specific command.\n"
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #parse ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
25 26 27 28 |
# File 'lib/bartask/cli.rb', line 25 def initialize(argv) @argv = argv = {} end |
Class Method Details
.start(argv = ARGV) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/bartask/cli.rb', line 5 def start(argv = ARGV) cli = new(argv) = cli.parse if [:mode] == "r" Bartask::Restorer.new(config_file_path: [:config], dump_file_path: [:dump]).execute else Bartask::Dumper.new(config_file_path: [:config], dump_file_path: [:dump]).execute end end |
Instance Method Details
#parse ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bartask/cli.rb', line 30 def parse global_command.order!(@argv) [:mode] = @argv.shift subcommand = subcommands[[:mode]] unless subcommand puts global_command.help exit! end subcommand.order!(@argv) end |