aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2017-06-04README: Change description wordingTeddy Wing
I personally think this tool "vastly improves" upon the Chrome extension. After all, it's much more flexible, and it lives in the console, both of which are immense pluses.
2017-06-04README: Improve readability of command line exampleTeddy Wing
Split the example code onto multiple lines to improve readability.
2017-06-04README: Add an additional Usage exampleTeddy Wing
I thought it would be cool if we showed off an example connecting `timetasker` with another shell command.
2017-06-04README: Move URLs to bottom of fileTeddy Wing
Makes it a bit easier to read as text.
2017-06-04README: Add Install sectionTeddy Wing
Installation instructions.
2017-06-04README: Add Configuration sectionTeddy Wing
Explain the program's configuration and how to configure it using data from TimeTask.
2017-06-04README: Add Usage sectionTeddy Wing
Show some examples of how to use the program.
2017-06-04README: Rewrite the opening descriptionTeddy Wing
Remove references to the project being abandoned. Briefly describe it.
2017-06-04Merge branch 'move-http-errors-to-http.go' into timetasker-dailyTeddy Wing
2017-06-04Update TODOTeddy Wing
2017-06-04Move HTTP response body errors into http.goTeddy Wing
Take the errors in `main()` that check the response body contents for known error strings and put them in their respective functions in "timetask/http.go". Didn't really make sense to me that these functions were returning HTTP responses that we weren't really using in a meaningful way. Instead they should just do their thing and let us know if there was a problem. That includes checking to see if there were any non-standard errors, like the ones we had custom-built. Now all that handling and error-making is self-contained, which feels much nicer.
2017-06-04Merge branch 'command-to-get-module-ids-of-project' into timetasker-dailyTeddy Wing
2017-06-04Update TODOTeddy Wing
2017-06-04RequestModules(): Pretty print modulesTeddy Wing
Parse the module XML with `ModuleParseXML()`. Take the resulting `[]Module` slice and use it to generate a string of the following format: ID Module 55555 R&D 77777 Sprint 1 222222 Sprint 2 This string is what gets printed to the console, which makes it rather easy to read the modules that are available for the given project and grab the appropriate ID to put into your config file.
2017-06-04Change `ParseXML()` name to `ModuleParseXML()`Teddy Wing
Prefix the function name to make it more obvious what it relates to. Since this function lives in the `timetask` module and will be used in contexts that have nothing to do with Modules.
2017-06-04Add module.go for parsing Module XMLTeddy Wing
A new function that parses the XML returned by the `RequestModules()` function. It provides a `Module` type that allows us to interact with modules more easily in code. The `ParseXML()` function will take an XML string and return a slice of `Module`s. Added a test just to facilitate development. Wasn't able to find an easy way to compare slices in Go, so just printed the values and checked the result visually. Not a useful test for future use, but it served its purpose. Eventually it would be nice to find a way to compare structs and have a real pass/fail condition.
2017-06-03TestLogin(): Fix `Login()` assignment mismatchTeddy Wing
`Login()` now returns 3 values. Update the test.
2017-06-03Add an option to list "Modules" (sprints & their IDs)Teddy Wing
Sprints will change with time while the other IDs of a project will stay the same. Thus sprints, which live in the `Module` field, must be updated regularly. In order to facilitate that updating, instead of requiring users to get those IDs directly from the TimeTask website every time, have them use this command to get the names of sprints and their IDs. They can then update the ID manually in their config file. This code makes a request to the endpoint that returns module IDs for the site (the site queries this via AJAX to update its interface). The result of the request is some XML containing the modules and their IDs. For now I'm just printing this out. We'll want to parse the XML and display it in a nicer way.
2017-06-03Update TODOTeddy Wing
2017-06-03Merge branch 'handle-failing-responses-from-the-server' into timetasker-dailyTeddy Wing
2017-06-03Update TODOTeddy Wing
2017-06-03main(): Handle errors from HTTP responsesTeddy Wing
Add some simple error handling for known responses from our TimeTask HTTP requests. Check a couple of known strings to determine whether there was an error. If so, exit with a failing error code. Remove our old `log` statements. These were used during debugging to see some output and check responses from TimeTask. We now have an idea of what those responses are, and are handling some of the error cases. Thus the log statements are no longer needed.
2017-06-03main(): Add comment explaining `--project` validationTeddy Wing
2017-06-03main(): Change Kingpin error messages to lowercaseTeddy Wing
Remove the initial cap on Kingpin error messages for consistency in our messages.
2017-06-03Update TODOTeddy Wing
2017-06-03Merge branch 'load-from-xdg-config' into timetasker-dailyTeddy Wing
2017-06-03main(): Move `loadConfig()` call after CLI argument parsingTeddy Wing
Otherwise, if users haven't created a config file and they run `--help`, they'll get an error complaining that the config file doesn't exist instead of helpful usage output.
2017-06-03main(): Update error message for `loadConfig()` errorTeddy Wing
* Change the initial capital to lowercase for consistency with the other error messages * Suggest using `--write-config` as a possible solution to the error (in cases where the config file doesn't exist)
2017-06-03loadConfig(): Load from real XDG configTeddy Wing
Instead of loading the config file I've been testing with in the local project directory, load the real one from XDG_CONFIG_HOME.
2017-06-03Update TODOTeddy Wing
2017-06-03Merge branch 'password-cmd' into timetasker-dailyTeddy Wing
2017-06-03Make the `password_cmd` config setting workTeddy Wing
Given a string from `password_cmd`, we should execute it as a shell command and assume the result is a password. That password then gets submitted to TimeTask's login form for authentication. Had to do a bit of wrangling to get the command to execute by `exec.Command()`, but managed to get it working in a bit of a roundabout way. Found these resources in my searches: - https://stackoverflow.com/questions/39930109/golang-execute-command#39930127 https://stackoverflow.com/questions/28783637/how-to-make-golang-execute-a-string - https://stackoverflow.com/questions/20437336/how-to-execute-system-command-in-golang-with-unknown-arguments - https://github.com/codeskyblue/go-sh
2017-06-03main.go: Fix whitespaceTeddy Wing
Thanks gofmt
2017-06-03Merge branch 'use-kingpin-error-helpers' into timetasker-dailyTeddy Wing
2017-06-03Update TODOTeddy Wing
2017-06-03Merge branch 'config-initialiser' into timetasker-dailyTeddy Wing
2017-06-03main(): Change error handling to use Kingpin error helpersTeddy Wing
In order to maintain a consistent format when echoing error messages, use the Kingpin helpers to do so. Rewrite our error message code to this effect. This has the added benefit of making our code shorter.
2017-06-03main.go: Custom `Required()` for `--project` argumentTeddy Wing
As far as I've been able to figure out, Kingpin doesn't have a mechanism for dependent arguments or conditional requireds. Thus there's no way to say "--position is only required if --write-config isn't passed". In that case, write our own "required" check, to enforce the presence of "--project" only if "--write-config" isn't passed. We duplicate the message that Kingpin provides from `Required()` and leverage its error formatting (we should probably use this for our other error messages too). The only difference is that `--position=POSITION` won't appear on the first line of the Help text, which would have emphasised the fact that it's required. It's possible to configure Kingpin's help text via templates, but I don't think that's worth the trouble at this point.
2017-06-03main.go: If `--write-config` is passed, do work and exitTeddy Wing
Ensure that we're not actually submitting a time entry if the `--write-config` flag was passed. In that case, we just want to write the empty config file and exit successfully.
2017-06-03main.go: Only call `maybeWriteConfig()` when `--write-config` is givenTeddy Wing
We shouldn't automatically force writing the config file. Only do so if the user asks for it to be done. NOTE: there's a problem here, because `-p` is required but it shouldn't be in this specific case.
2017-06-03config.go: Extract config file paths to functionsTeddy Wing
Put these constructed paths into reusable functions for easier usage.
2017-06-03main.go: Handle errors coming from `loadConfig()`Teddy Wing
2017-06-03Make `MaybeWriteConfig()` a private functionTeddy Wing
I figured it would be a good idea to make this function and `loadConfig()` consistent. Since `loadConfig()` is private, make this one private also.
2017-06-03Move `Config` & `loadConfig()` to config.goTeddy Wing
Now that we have a 'config.go' file, it makes more sense for these two to live in that file. Change `loadConfig()` to return an error instead of printing it to the log.
2017-06-03main.go: Handle errors from MaybeWriteConfig()Teddy Wing
If the function results in an error, print it and exit.
2017-06-03MaybeWriteConfig(): Write an empty config fileTeddy Wing
If no existing config file is found, write a sample config file to XDG_CONFIG_HOME/timetasker/config.toml.
2017-06-03Add `MaybeWriteConfig()`Teddy Wing
A new function that will write a new config.toml file to the XDG_CONFIG_HOME directory. Currently it checks to see whether our config file is present. If not and our config directory isn't present, it creates it. Still need to get this to actually write the config file. Also, we won't want to call it by default in main() like we're doing now. Will likely want to hide it behind a `--write-config` flag.
2017-06-03Update TODOTeddy Wing
2017-06-03Merge branch 'fix-time-format-bug' into timetasker-dailyTeddy Wing
2017-06-03buildSubmissionParams(): Fix time string replacement bugTeddy Wing
We ran into a bug where submitting "7" as the time spent would become "700" on the site. This was because our `n` value of 0 wasn't replacing the "." in the string. Thus "7.00" became "7.00" after the replacement. Not right. I misunderstood what that argument was doing and what the word "empty" in the documentation meant. Change the `n` value to replace all "."s in the string.