toggl_cli 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/toggl_cli +24 -0
  3. data/lib/toggl_cli.rb +34 -0
  4. metadata +59 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 39434717adfc3f61507f0660246fcd302623aba0e4c70f6a005077a38c2843c4
4
+ data.tar.gz: 0c957be256d4d4f9a3b534c3e592c2ad73a718450f3f08412c8534f2d3088ac2
5
+ SHA512:
6
+ metadata.gz: fa32da5a5ddd147faf30eccb3263e93a485ab8066c68181cadba7cee73bd593dbf91d15df79970a490f013c63987c9838a3d93191143bc2c2ada9613f064f1b0
7
+ data.tar.gz: c2dfb832386b5f63029ae668e20d376cdf83214b4dc8cd02ee2608817613a42269f4f4e73db1cbbb3e8f61b8ddea451682b08465c5dfb063792d2698cf769510
data/bin/toggl_cli ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'toggl_cli'
4
+
5
+ @toggl_cli = TogglCLI.new
6
+
7
+ command = ARGV[0]
8
+ if !command
9
+ puts "Please specify a command"
10
+ exit 1
11
+ end
12
+
13
+ case command
14
+ when 'start'
15
+ project = ARGV[1]
16
+ description = ARGV[2]
17
+ @toggl_cli.start(project, description)
18
+ puts "Timer Started"
19
+ when 'stop'
20
+ @toggl_cli.stop
21
+ puts "Timer Stopped"
22
+ else
23
+ puts "Uh-oh! I haven't learned that command yet"
24
+ end
data/lib/toggl_cli.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'togglv8'
2
+ require 'json'
3
+ require 'yaml'
4
+
5
+ class TogglCLI
6
+ def initialize
7
+ @config = YAML.load_file(File.join(Dir.home, '.toggl_cli.yml'))
8
+ @toggl_api = TogglV8::API.new(@config['api_key'])
9
+ @user = @toggl_api.me(all=true)
10
+ @workspaces = @toggl_api.my_workspaces(@user)
11
+ @workspace_id = @workspaces.first['id']
12
+ end
13
+
14
+ def start(project, description)
15
+ pid = ""
16
+ if @config['projects'][project]
17
+ pid = @config['projects'][project]
18
+ end
19
+ time_entry = @toggl_api.start_time_entry({
20
+ 'pid' => pid,
21
+ 'description' => "#{description}",
22
+ 'wid' => @workspace_id,
23
+ 'start' => @toggl_api.iso8601((Time.now).to_datetime),
24
+ 'created_with' => "toggl_cli"
25
+ })
26
+ end
27
+
28
+ def stop
29
+ current = @toggl_api.get_current_time_entry
30
+ if current
31
+ result = @toggl_api.stop_time_entry(current['id'])
32
+ end
33
+ end
34
+ end
metadata ADDED
@@ -0,0 +1,59 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: toggl_cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Blake Erickson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: togglv8
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ description:
28
+ email:
29
+ executables:
30
+ - toggl_cli
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/toggl_cli
35
+ - lib/toggl_cli.rb
36
+ homepage: https://github.com/oblakeerickson/toggl_cli
37
+ licenses:
38
+ - MIT
39
+ metadata: {}
40
+ post_install_message:
41
+ rdoc_options: []
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ requirements: []
55
+ rubygems_version: 3.0.1
56
+ signing_key:
57
+ specification_version: 4
58
+ summary: A simple command line tool for toggl
59
+ test_files: []