zenhob / hcl Goto Github PK
View Code? Open in Web Editor NEWCommand-line tool for manipulating Harvest timesheets
Home Page: http://zenhob.github.io/hcl
License: MIT License
Command-line tool for manipulating Harvest timesheets
Home Page: http://zenhob.github.io/hcl
License: MIT License
Making diligent use of the ticketing system...I'm guessing the above error means ruby isn't checking the SSL cert, but don't know how to fix it.
Problem: The user is forced to choose whether to enable SSL. It's possible to choose the wrong option.
Solution: SSL should be auto-detected. Even the sample client from Harvest does this.
Sometimes hcl fails to recognize existing aliases until you issue a show command. It also provides a rather useless suggestion:
$ hcl start foo documentation. workflow.
Unknown project/task alias, try one of the following: personal, upto, hcl, system, pto, process, foo
$ hcl start foo documentation. workflow.
Unknown project/task alias, try one of the following: personal, upto, hcl, system, pto, process, foo
$ hcl show
0:27 <REDACTED>
0:14 (running) <REDACTED>
-------------
0:42 total
$ hcl start foo documentation. workflow.
Started timer for Foo Software Development.
It should be possible to run hcl interactively without having to create a yaml config file. At the very least, the domain, login and password must be configurable from the command line.
I switch back and forth between tasks sometimes quite frequently. It'd be nice to be able to use resume (or even start) to try to auto-match an existing timer for the day based on the passed args.
For example, I have an alias of 'internal' which I dump some generic time into without notes. It'd be nice to keep just one entry rather than have twenty in a day:
hcl start internal
hcl stop
hcl start 1234 4567 some log
hcl stop
hcl resume internal
hcl stop
hcl start 1234 4567 another log
hcl stop
hcl resume 1234 4567 some log
hcl show
0:10 1234 1234
0:30 (running) 1234 4567 some log
0:05 1234 4567 another log
Problem: The README encourages the user to add:
eval `hcl completion`
to their bashrc, but it can take a second to load hcl and the delay in starting the shell can be noticeable.
Solution: The completion command just prints a bash complete
wrapped around the defined task aliases, so instead of forcing the user to run hcl to access the aliases, dump an easy-to-read list of aliases in $HCL_DIR
. Then the command used to define completion doesn't need to run hcl anymore:
complete -W `cat ~/.hcl/aliases` hcl
Problem: No versions are specified in the gemspec. This can cause errors if end users aren't all using the same version of an API. See #53
Solution: Specify detailed version requirements in the gemspec.
Escaped XML is showing up in the output. It looks like some values need to be unescaped before display:
~$ hcl note moved central irc node to test.
Added note 'moved central irc node to test.' to Internal Systems & Networking (0:53).
I think this is masking another issue. In any case, when HCl gets XML input that it doesn't know what to do with, the correct response is not to freak out, like it does here:
/Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl/task.rb:5:in cache_tasks': undefined methodelements' for nil:NilClass (NoMethodError)
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl/day_entry.rb:18:in `from_xml'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl/day_entry.rb:9:in `all'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl.rb:222:in `show'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl.rb:44:in `send'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl.rb:44:in `run'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/lib/hcl.rb:38:in `command'
from /Library/Ruby/Gems/1.8/gems/zenhob-hcl-0.2.1/bin/hcl:6
from /usr/bin/hcl:19:in `load'
from /usr/bin/hcl:19
A good short-term solution would probably be to report a problem with the XML results. Not sure what else yet, or what the known workarounds are, if any.
Thanks radar for putting me on to this.
Start a time at 23:50, try to stop it at 00:10 and see "No running timers found."
Currently output is limited to 78 characters. Gotta find a reliable way to determine terminal width.
The problem is right now I'm using task IDs to create new timers:
$ hcl start 123923 some stuff
One possible solution would be to define and use aliases.
$ hcl set task.projectdev 123923
$ hcl start projectdev some stuff
Is it possible to grab the timesheet entries of other people in your organisation with hcl?
So that I could build up a timesheet for an entire team across a week say?
Many thanks!
Patrick
Currently hours are always displayed in decimal. It would be nice to have them in HH:MM.
I do have the chronic gem installed though...
jonathan@hyperion:~/git/hcl$ ls /var/lib/gems/1.8/gems/
chronic-0.2.3 highline-1.5.1 trollop-1.14
jonathan@hyperion:~/git/hcl$ hcl
/home/jonathan/git/hcl/bin/../lib/hcl.rb:6:in require': no such file to load -- chronic (LoadError) from /home/jonathan/git/hcl/bin/../lib/hcl.rb:6 from /home/jonathan/git/hcl/bin/hcl:6:in
require'
from /home/jonathan/git/hcl/bin/hcl:6
When I invoke hcl tasks
and put in my information, when I get done (and then on subsequent runs until I remove ~/.hcl/config.yml
), I get the following error:
/Users/me/.rvm/gems/ruby-1.9.3-p448/gems/hcl-0.4.11/lib/hcl/timesheet_resource.rb:42:in `block in resources': wrong number of arguments (0 for 1) (ArgumentError)
from /Users/me/.rvm/gems/ruby-1.9.3-p448/gems/hcl-0.4.11/lib/hcl/commands.rb:21:in `tasks'
from /Users/me/.rvm/gems/ruby-1.9.3-p448/gems/hcl-0.4.11/lib/hcl/app.rb:44:in `run'
from /Users/me/.rvm/gems/ruby-1.9.3-p448/gems/hcl-0.4.11/lib/hcl/app.rb:27:in `command'
from /Users/me/.rvm/gems/ruby-1.9.3-p448/gems/hcl-0.4.11/bin/hcl:4:in `<top (required)>'
from /Users/me/.rvm/gems/ruby-1.9.3-p448/bin/hcl:23:in `load'
from /Users/me/.rvm/gems/ruby-1.9.3-p448/bin/hcl:23:in `<main>'
This happens when using hcl
v0.4.11. I tried all permutations of SSL on/off and subdomain long/short (see below). I get a different error with v0.4.10 related to "undefined method `register_middleware' for #Faraday::Connection:0x007fa384869118 (NoMethodError)". v0.4.9 seems to work without any issues.
Side note: I wasn't sure what to put in for the subdomain (mysubdomain vs. mysubdomain.harvestapp.com), we might clarify that in the instructions. It seems like the former works just fine.
➜ ~ gem install hcl
Building native extensions. This could take a while...
ERROR: Error installing hcl:
ERROR: Failed to build gem native extension.
/Users/adamyonk/.rbenv/versions/1.9.3-rc1/bin/ruby extconf.rb
checking for termios.h... yes
checking for unistd.h... yes
creating Makefile
make
compiling termios.c
In file included from termios.c:10:
/Users/adamyonk/.rbenv/versions/1.9.3-rc1/include/ruby-1.9.1/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"
termios.c: In function ‘Termios_to_termios’:
termios.c:182: error: ‘struct RArray’ has no member named ‘ptr’
termios.c:183: error: ‘struct RArray’ has no member named ‘ptr’
termios.c: In function ‘termios_tcgetattr’:
termios.c:200: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:200: error: (Each undeclared identifier is reported only once
termios.c:200: error: for each function it appears in.)
termios.c:200: error: ‘fptr’ undeclared (first use in this function)
termios.c: In function ‘termios_tcsetattr’:
termios.c:224: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:224: error: ‘fptr’ undeclared (first use in this function)
termios.c:225: warning: ISO C90 forbids mixed declarations and code
termios.c:231: warning: initialization discards qualifiers from pointer target type
termios.c: In function ‘termios_tcsendbreak’:
termios.c:265: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:265: error: ‘fptr’ undeclared (first use in this function)
termios.c: In function ‘termios_tcdrain’:
termios.c:290: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:290: error: ‘fptr’ undeclared (first use in this function)
termios.c: In function ‘termios_tcflush’:
termios.c:313: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:313: error: ‘fptr’ undeclared (first use in this function)
termios.c:314: warning: ISO C90 forbids mixed declarations and code
termios.c: In function ‘termios_tcflow’:
termios.c:343: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:343: error: ‘fptr’ undeclared (first use in this function)
termios.c:344: warning: ISO C90 forbids mixed declarations and code
termios.c: In function ‘termios_tcgetpgrp’:
termios.c:374: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:374: error: ‘fptr’ undeclared (first use in this function)
termios.c:375: warning: ISO C90 forbids mixed declarations and code
termios.c: In function ‘termios_tcsetpgrp’:
termios.c:398: error: ‘OpenFile’ undeclared (first use in this function)
termios.c:398: error: ‘fptr’ undeclared (first use in this function)
make: *** [termios.o] Error 1
Gem files will remain installed in /Users/adamyonk/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/termios-0.9.4 for inspection.
Results logged to /Users/adamyonk/.rbenv/versions/1.9.3-rc1/lib/ruby/gems/1.9.1/gems/termios-0.9.4/./gem_make.out
For now I'm assuming that only one timer can be running at a time.
Problem: It's possible to use cancel
repeatedly to clear your daily timesheet.
Solution: Get user confirmation before removing non-running timer entries with cancel
Not sure if this is possible, but how would I go about removing an alias?
Harvest will soon be removing the ability to make non-SSL API requests.
All Harvest accounts now support SSL, so the option should be removed.
The command line time tracker for Mite (https://github.com/Overbryd/mite.cmd) supports tab completion of projects/tasks, which is really handy. I'd like to be able to do something like:
Project1
Project2
And the same for tasks. Hopefully this can be mostly copied form mite.cmd.
Currently the configuration is stored in a yaml file in the project directory. Instead it should be using $HOME/.hclrc or similar.
I switched from the old auto completion script:
eval `hcl completion`
to the new one:
complete -W `cat ~/.hcl/aliases` hcl
and I get the following error on CLI:
cat: /Users/username/.hcl/aliases: No such file or directory
complete: usage: complete [-abcdefgjksuv] [-pr] [-o option] [-A action] [-G globpat] [-W wordlist] [-P prefix] [-S suffix] [-X filterpat] [-F function] [-C command] [name ...]
...which makes sense, because when I look in the .hcl
directory, there isn't an aliases
directory/file. Currently, all of the aliases are being saved to a settings.yml
file. Replacing settings.yml
in the script doesn't fix the issue either.
The latest version is requiring that I install the hcl gem. However, when I first went to do so, I got this:
jonathan@hyperion:~/git/hcl$ sudo gem install zenhob-hcl --source=http://gems.github.com
ERROR: Error installing zenhob-hcl:
zenhob-hcl requires termios (>= 0, runtime)
After a bit of digging, the way to enable this on Ubuntu machines is via libtermios-ruby package. I then got an error that mkmf was missing.
After a bit more digging, it turns out that ruby-dev is required with the latest version.
sudo apt-get install ruby-dev
sudo gem install termios
After that, everything started working again.
The way tasks aliases are currently implemented is not ideal from a UI perspective. There should be a way to guide this process, at least. Either that or figure out a solution that does away with aliases entirely.
Change this file to only be readable by user:
$ chmod 400 ~/.hcl_config
$ ls -la ~/.hcl_*
-r-------- 1 user user 87 2012-05-31 14:11 /home/user/.hcl_config
I ran the above command and am still able to run hcl.
Could this be integrated into the creation of this file?
A better solution would be to encrypt the password somehow, but readable by your user only is a start.
You should be able to specify a starting point for the hours when starting a new timer, something like this:
$ hcl start mytask +0:15 these are my time log notes
The argument parsing is either terrible or nonexistent. Use a real argument parsing library like Trollop.
HCl should be installable directly from git using rip. Technically it can be installed but it fails to run when it cannot find the VERSION file, which is included in the gem but not the rip install. Not sure the correct approach, should I replicate the version number in the code instead? Should I just remove the --version option? I guess you can check which version you have installed by querying rubygems or rip.
HCl needs to be installable and packaged as a gem.
A nice feature would be to have HCL able to report total cumulative booked time for a given period (default: the current week), across all projects.
It would then be possible to ascertain, given a total number of hours required for the week, where one stands in relation to the total.
Include a command that displays a weekly timesheet for end-of-week review and similar. Something like the following:
$ hcl weekly
$ hcl weekly last week
Is it possible to do something along the lines of hcl show this week
with chronic?
For example, executing that on Wednesday would show you hours and tasks from Sunday - Wednesday.
If I start a timer, then attempt to start another timer without first typing 'hcl', i get this error:
$ hcl start foobar some words
/var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:166:in `start': undefined method `start' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in `send'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in `run'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:35:in `command'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/hcl:8
Once I type 'hcl' and hit enter, then the above command works fine.
Sometimes when starting a timer I get a failure and stacktrace like the one below. Issuing the show command before trying again seems to fix it.
/var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:166:in `start': undefined method `start' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in `send'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in `run'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:35:in `command'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/hcl:8
from /var/lib/gems/1.8/bin/hcl:19:in `load'
from /var/lib/gems/1.8/bin/hcl:19
Suggested by pvh:
as a side note, it would be nice to have hcl log +1 fixed that thing which wouldn't leave a timer running.
My company has a lot of tasks. Currently, to search for a specific task, I pipe hcl tasks
into grep. It'd be nice if I could filter that huge list in hcl (e.g. hcl tasks [client_filter] [task_filter]
)
Once I get this tested and solidified I should look into integrating the timesheet features into aiaio's harvest gem.
Any time the command line options are invalid or incorrect, the user sees a stack trace. They should instead see a usage message of some sort.
Turns out this is caused by the fact that HCl only supports SSL-based requests at the moment.
Bug report from pvh:
I just installed hcl from a gem today and ran into an error which I couldn't find logged anywhere:
compvher:songbird(podcast-detection) pvh$ hcl show
Internal failure. No root node in XML document: Redirected to http://, see the Location header
I checked my email, password and subdomain, and tested a manual authentication by poking at harvest with curl and it looks like my settings are all correct.
I kept getting this error:
no such file to load -- net/https (LoadError)
For us ruby n00bs, this was the only stumbling block I had in getting it running. Apparently, on Ubuntu, this comes with a package called libopenssl-ruby, so a note in the README about this would have made the process seamless.
Right now it's not possible to delete a time sheet entry. Once we have #9 just having the ability to delete the last (and/or current) entry would be sufficient.
hcl start dev +1 foo gives me a task with a starting time of (0:00)
hcl start dev +1.0 foo gives me a task with a starting time of (1:00)
1:00 == 1.0 so it should be safe enough to simply treat integers as hours.
(as a side note, it would be nice to have hcl log +1 fixed that thing
which wouldn't leave a timer running.)
/Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/faraday-0.9.0/lib/faraday.rb:99:in `method_missing': undefined method `register_middleware' for #<Faraday::Connection:0x00000104848b18> (NoMethodError)
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/harvest_middleware.rb:4:in `<class:HarvestMiddleware>'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/harvest_middleware.rb:3:in `<top (required)>'
from /Users/brynbodayle/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/brynbodayle/.rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/net.rb:1:in `<top (required)>'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/app.rb:158:in `request_config'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/app.rb:147:in `read_config'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/app.rb:20:in `initialize'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/app.rb:27:in `new'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/lib/hcl/app.rb:27:in `command'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/gems/hcl-0.4.10/bin/hcl:4:in `<top (required)>'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/bin/hcl:23:in `load'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/bin/hcl:23:in `<main>'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `eval'
from /Users/brynbodayle/.rvm/gems/ruby-2.1.0/bin/ruby_executable_hooks:15:in `<main>'
I get this whenever trying to run "hcl tasks".
Any thoughts?
jonathan@hyperion:~/git/hcl$ hcl start 102446 326634 further testing of hobson's hcl client
/home/jonathan/git/hcl/bin/../lib/hcl.rb:116:in start': undefined method
[]' for nil:NilClass (NoMethodError)
from /home/jonathan/git/hcl/bin/../lib/hcl.rb:32:in send' from /home/jonathan/git/hcl/bin/../lib/hcl.rb:32:in
run'
from /home/jonathan/git/hcl/bin/../lib/hcl.rb:26:in `command'
from /home/jonathan/git/hcl/bin/hcl:9
The note command seems inoperable in HCl 0.2.2:
/var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/lib/hcl/day_entry.rb:33:in `append_note': undefined method `<<' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/lib/hcl/app.rb:213:in `note'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/lib/hcl/app.rb:48:in `send'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/lib/hcl/app.rb:48:in `run'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/lib/hcl/app.rb:41:in `command'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.2.2/bin/hcl:5
from /var/lib/gems/1.8/bin/hcl:19:in `load'
from /var/lib/gems/1.8/bin/hcl:19
I did a quick check of the source, this is very mysterious indeed. I need to roll back b0738c3 and figure out a different approach.
I started a task w/o a note, then get this when I try to add a note:
jonathan@hyperion:~/svn/clients/bef/main/trunk/drupal$ hcl note email
/var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl/day_entry.rb:29:in append_note': undefined method
<<' for nil:NilClass (NoMethodError)
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:184:in note' from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in
send'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:41:in run' from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/../lib/hcl.rb:35:in
command'
from /var/lib/gems/1.8/gems/zenhob-hcl-0.1.1/bin/hcl:8
In the daily time sheet hours are displayed as HH:MM, but there are cases (adding notes and stopping timers come to mind) where the length of an affected timer is displayed in floating-point. Time spans should always display in the same format (which is HH:MM for the moment).
When starting a new timer the output is missing a task name:
~/Projects/hcl$ hcl start 109541 email. tickets.
Starting timer for Clove Software Development
Time is running on
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.