Module: Hbtrack::CLI

Defined in:
lib/hbtrack/cli/cli.rb,
lib/hbtrack/cli/view.rb

Defined Under Namespace

Modules: View

Class Method Summary collapse

Class Method Details

.helpObject



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/hbtrack/cli/cli.rb', line 35

def help
  puts 'Usage: hbtrack <command> [<habit_name>] [options]'
  puts
  puts 'Commands:'
  puts '     add: Add habit(s)'
  puts '     remove: Remove habit(s)'
  puts '     list: List habit(s)'
  puts '     show: Show habit'
  puts '     done: Mark habit(s) as done'
  puts '     undone: Mark habit(s) as undone'
  puts '     import: Import data from files'
  puts
  puts 'Options:'
  puts "     -h, --help\t\tShow help messages of the command"
  exit
end

.run(store_path = DB_PATH, args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/hbtrack/cli/cli.rb', line 13

def run(store_path = DB_PATH, args)
  command = case args.shift
            when 'list'
              ListCommand.new(store_path, args)
            when 'show'
              ShowCommand.new(store_path, args)
            when 'done'
              UpdateCommand.new(store_path, args, true)
            when 'undone'
              UpdateCommand.new(store_path, args, false)
            when 'remove'
              RemoveCommand.new(store_path, args)
            when 'add'
              AddCommand.new(store_path, args)
            when 'import'
              ImportCommand.new(store_path, args)
            else
              help
            end
  puts command.execute
end