Module: WorkMd::Cli
- Defined in:
- lib/work_md/cli.rb
Defined Under Namespace
Classes: CommandMissing
Constant Summary collapse
- ALIAS_COMMANDS =
{ 't' => 'today', 'ty' => 'tyesterday', 'y' => 'yesterday', 'c' => 'config', 'p' => 'parse', 'a' => 'annotations' }.freeze
Class Method Summary collapse
Class Method Details
.error_frame_style ⇒ Object
61 62 63 64 65 66 |
# File 'lib/work_md/cli.rb', line 61 def self.error_frame_style { padding: 1, title: { top_left: '(error)' } } end |
.execute(argv) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/work_md/cli.rb', line 17 def self.execute(argv) first_argv_argument = argv.shift raise CommandMissing if first_argv_argument.nil? command = (ALIAS_COMMANDS[first_argv_argument] || first_argv_argument).capitalize Object .const_get("WorkMd::Commands::#{command}") .send(:execute, argv) rescue NameError puts help( ::TTY::Box.frame( "Command '#{first_argv_argument}' not found!", **error_frame_style ) ) rescue CommandMissing help('Welcome! =)') end |
.help(message = '') ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/work_md/cli.rb', line 39 def self.help( = '') # rubocop:disable Layout/LineLength puts ::TTY::Box.frame( , 'Track your work activities, write annotations, recap what you did for a week, month or specific days... and much more!', '', 'commands available:', '', '- work_md', '- work_md today', '- work_md yesterday', '- work_md tyesterday', '- work_md parse', '- work_md config', '', 'more information in github.com/henriquefernandez/work_md', padding: 1, title: { top_left: '(work_md)', bottom_right: "(v#{WorkMd::VERSION})" } ) # rubocop:enable Layout/LineLength end |