bin/frecli
#!/usr/bin/env ruby
require 'gli'
require 'frecli'
include GLI::App
include Frecli::Settings
program_desc 'Freckle CLI'
version Frecli::VERSION
subcommand_option_handling :normal
arguments :strict
desc 'Shows the current timing status'
command :status do |c|
c.action do
Frecli::Cli.status
end
end
desc 'Times a project'
arg_name 'project_query'
command :time do |c|
c.action do |_, _, args|
project_query = args.shift.to_s
Frecli::Cli.time(project_query)
end
end
desc 'Pauses the running timer'
command :pause do |c|
c.action do
Frecli::Cli.pause
end
end
desc 'Logs the running timer'
arg_name 'description', :optional
command :log do |c|
c.action do |_, _, args|
description = args.shift.to_s
Frecli::Cli.log(description)
end
end
desc 'Lists projects'
arg_name 'refresh', :optional
command :projects do |c|
c.action do |_, _, args|
refresh = args.shift
Frecli::Cli.projects(refresh: refresh)
end
end
pre do |global,command,options,args|
# Pre logic here
# Return true to proceed; false to abort and not call the
# chosen command
# Use skips_pre before a command to skip this block
# on that command only
true
end
post do |global,command,options,args|
# Post logic here
# Use skips_post before a command to skip this
# block on that command only
end
on_error do |exception|
# Error logic here
# return false to skip default error handling
true
end
exit run(ARGV)