Class: GitWakaTime::Cli
- Inherits:
-
Thor
- Object
- Thor
- GitWakaTime::Cli
- Includes:
- Thor::Actions
- Defined in:
- lib/gitwakatime/cli.rb
Overview
Provides two CLI heartbeats init and tally
Instance Method Summary collapse
Instance Method Details
#init ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/gitwakatime/cli.rb', line 21 def init unless File.exist?(File.join(Dir.home, '.wakatime.yml')) api_key = ask('What is your wakatime api key? ( Get it here https://wakatime.com/settings):') say('Adding .wakatime.yml to home directory') create_file File.join(Dir.home, '.wakatime.yml') do YAML.dump(api_key: api_key, last_commit: nil, log_level: :info) end end reset end |
#reset ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/gitwakatime/cli.rb', line 34 def reset DB.disconnect db_path = File.(File.join(Dir.home, '.wakatime.sqlite')) FileUtils.rm_r(db_path) if File.exist?(db_path) DB.connect("sqlite://#{db_path}") GitWakaTime.config.setup_local_db end |
#tally ⇒ Object
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gitwakatime/cli.rb', line 48 def tally date = Date.parse(.start_on) @timer = GitWakaTime::Controller.new( path: File.(.file), date: date ).timer print_output(@timer, format: .output) end |
#update ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/gitwakatime/cli.rb', line 61 def update GitWakaTime.config.setup_local_db GitWakaTime.config.load_config_yaml date = Date.parse(.start_on || GitWakaTime::Heartbeat.max(:time)) GitWakaTime::Query.new(date, Date.today, @project).call end |