项目作者: prikhi

项目描述 :
A Redmine CLI Client and API Library Written in Haskell.
高级语言: Haskell
项目地址: git://github.com/prikhi/hkredmine.git
创建时间: 2014-09-20T08:07:57Z
项目社区:https://github.com/prikhi/hkredmine

开源协议:GNU General Public License v3.0

下载


HKRedmine

A Redmine CLI client written in Haskell.

You can do things like track time towards an Issue, create new Issues, view
Versions & Projects, filter & sort Issues, etc.

You can also reuse the API library for your own projects.

Quickstart

  1. Clone this repository: git clone http://bugs.sleepanarchy.com/hkredmine.git
  2. Install hkredmine: cd hkredmine; cabal install -j
  3. Add it to your path: export PATH=$PATH:~/.cabal/bin
  4. Add your Redmine URL to the config file: echo 'url=http://redmine.yourdomain.com/' > ~/.hkredminerc
  5. And your API key: echo 'apikey="longalphanumericstring"' >> ~/.hkredminerc
  6. List available projects: hkredmine projects
  7. List the issues of a project: hkredmine issues -p <project_identifier>
  8. List the next version of a project: hkredmine nextversion <project_identifier>
  9. Start tracking time on an issue: hkredmine startwork <issue_id>
  10. Stop tracking time and create a new time entry: hkredmine stopwork
  11. Learn how to use everything else: hkredmine --help

Installation

No packages currently exist, if you have experience packaging Haskell programs
for Debian, Arch Linux, etc. please drop us a patch or some hints.

If you’re using Stack, you should be able to just run stack setup in
this directory, followed by stack install.

Otherwise, you will need to build and install directly from the source. You
will need cabal, git and zlib:

  1. # Arch-Linux
  2. sudo pacman -S cabal-install git zlib
  3. # Debian/Ubuntu
  4. sudo apt-get install cabal-install git zlib1g-dev

Next update your cabal package list:

  1. cabal update

Then grab the source:

  1. git clone http://bugs.sleepanarchy.com/hkredmine.git

Build and install the program:

  1. cd hkredmine
  2. cabal sandbox init
  3. cabal install -j

Then copy the executable somewhere in your path:

  1. sudo cp dist/build/hkredmine/hkredmine /usr/bin
  2. cp dist/build/hkredmine/hkredmine ~/.bin

You may then remove the hkredmine directory:

  1. cd ..
  2. rm -rf hkredmine

Configuration

hkredmine expects a configuration file at ~/.hkredminerc. It should follow
the basic INI key = value style. Only two settings are required, url and
apikey:

  1. # ~/.hkredminerc
  2. url = http://redmine.mydomain.com/
  3. apikey = "longalphanumericapikey"

Be sure to enclose the API key in quotes and to include the trailing slash in
the URL.

Multiple accounts may be used by putting keys under [AccountName] headers:

  1. # ~/.hkredminerc
  2. [account1]
  3. url = ...
  4. apikey = "..."
  5. [account2]
  6. url = ...
  7. apikey = "..."

You can then switch accounts using the use command, like so:

  1. hkredmine use account1
  2. hkredmine projects
  3. # Projects from account1 tracker are shown
  4. hkredmine use account2
  5. hkredmine projects
  6. # Projects from account2 tracker are shown

General Usage

Run hkredmine --help for a listing of available commands and options.
Run hkredmine <command> --help for additional help and available parameters
for a specific command.

You can generate bash completion files by passing the bash argument to the
help flag:

  1. hkredmine --help=bash > hkredmine.comp
  2. source hkredmine.comp

These will also work with zsh if you enable bashcompinit before sourcing the
completion file:

  1. autoload bashcompinit
  2. bashcompinit
  3. source hkredmine.comp

The following commands are currently available:

  1. Commands:
  2. use Switch to a different redmine account.
  3. [status] Print the current Account, Issue and Tracked Time.
  4. Projects:
  5. project Print the details of a Project.
  6. projects Print all Projects.
  7. Issues:
  8. issue Print the details of an Issue.
  9. issues Filter and Print Issues.
  10. watched Filter and Print your Watched Issues.
  11. newissue Create a New Issue.
  12. update Update an New Issue.
  13. close Close an Issue.
  14. watch Watch an Issue.
  15. unwatch Unwatch an Issue.
  16. Options:
  17. fields Print available field values(Statuses, Priorities, etc.).
  18. categories Print a Project's Categories.
  19. newcategory Create a Category.
  20. Time Tracking:
  21. startwork Start tracking time for an Issue.
  22. stopwork Stop time tracking and submit a time entry.
  23. pause Pause time tracking.
  24. resume Resume time tracking.
  25. abort Abort time tracking.
  26. Versions:
  27. version Print the details of a Version.
  28. versions Print all of a Project's Versions.
  29. nextversion Print the next Version due for a Project.

Creating Issues

You can use the newissue command to create a new Issue. You need to pass it a
project identifier and a subject:

  1. hkredmine newissue -p my_proj -s "Refactor Foobar Class"

If you want to write out a longer description, pass the -e flag to open up
your $EDITOR:

  1. export EDITOR=vim
  2. hkredmine newissue -p my_proj -s "Refactor that thing" -e

Once you happy with the description, save and quit. You might encounter issues
with asynchronous editors like gvim. You could make an alias:

  1. alias hkredmine="EDITOR=vim hkredmine"

Vim user’s may be interested in this syntax plugin. We
follow the *.redmine extension convention.

Updating Issues

You can modify existing Issues using the update command:

  1. hkredmine update 77 --priority High -t Bug --category=UI -n "Fix Category"

You can pass the -e flag to edit the description in your $EDITOR:

  1. hkredmine update 31 --priority Immediate -s "A NU Start" -e

Creating Field Options

Right now, you can only create new Categories for Projects, using the
newcateogry command:

  1. hkredmine newcategory a-project Models

The -m flag will assign any Issues in the Category to you:

  1. hkredmine newcategory my-dotfiles "Vim Plugins" -m

Viewing Things

You can use the projects command to list all Projects and the project
command to list one Project’s details:

  1. hkredmine projects
  2. hkredmine project my-projects-identifier

You can use the issues, watched and version commands to show Issues:

  1. hkredmine issues --project my-project --status "In Progress"
  2. hkredmine watched --sort=priority
  3. hkredmine version 12

And the issue command to show details of a single Issue:

  1. hkredmine issue 42

To view a Project’s available Versions, use versions:

  1. hkredmine versions my-projects-identifier

You can see the available Issue Statuses, Priorities, Categories or Time Entry
Activites using the fields and categories commands:

  1. hkredmine fields
  2. hkredmine categories a-project-with-categories

Time Tracking

You can initiate time tracking for an Issue by using the startwork command:

  1. hkredmine startwork 154

You can also pause, resume and abort time tracking:

  1. hkredmine pause
  2. hkredmine resume
  3. hkredmine abort

When you’re ready to submit a new time entry, run the stopwork command:

  1. hkredmine stopwork

You can skip the prompts by passing parameters on the command line:

  1. hkredmine stopwork --activity=Development --comment="Writing @stopwork@ documentation"

Closing Issues

When Issues are considered finished, you can run the close command:

  1. hkredmine close 154

This will change the Issue’s status to Closed, the done ratio to 100% and
the due date to today(but only if it is not already set).

You can specify a comment to leave when updating the Issue using the comment
flag:

  1. hkredmine close 69 --comment "Hotfix pushed to prod"

Workflow

Let’s begin our day by picking an account to use. This is only necessary is you
have accounts on multiple Redmine instances:

  1. hkredmine use sleepanarchy

As a quick refresher, we’ll see what Issues we are watching:

  1. hkredmine watched

Nothing we feel like tackling at the moment… Let’s checkout all available
projects:

  1. hkredmine projects

We find a project we want to work on, let’s check out the open issues in the
project’s next version:

  1. hkredmine nextversion acorn-accounting --sort priority:desc

We see an Issue that catches our eye, let’s see it’s details:

  1. hkredmine issue 154

Looks good, let’s mark it as “In Progress”, set the start date to today and
start tracking time towards the Issue:

  1. hkredmine startwork 154

An emergency has come up in a project that is on a different Redmine instance.
First, we’ll stop tracking time for the current Issue and create a new time
entry:

  1. hkredmine stopwork --type=Development --comment="Started writing tests."

We’ll switch to our account on the other Redmine instance, then create a new Issue:

  1. hkredmine use acorn
  2. hkredmine newissue --project=it-computers -t Support -i Immediate -e -s "Emergency Request"

Our editor should open up to let us enter a detailed description for the Issue.
After saving and exiting from our editor, the issue will be created. Let’s
start work on it:

  1. hkredmine startwork 280

While working on the Issue, we notice something out of scope and quickly make a
new issue:

  1. hkredmine newissue -p it-computers -t Bug -s "Something is wrong with X!"

Let’s watch it so we remember to come back to it:

  1. hkredmine watch 281

Finally, we’re done with the emergency Issue.Let’s stop work on it:

  1. hkredmine stopwork --activity=Administration --comment="Help Y with X."

Let’s mark the Issue as Closed, set the Due Date to today and the Done Ratio to
100%:

  1. hkredmine close 280

We can jump back to our first Issue now:

  1. hkredmine use sleepanarchy
  2. hkredmine startwork 154

After working a bit more, we go for a walk:

  1. hkredmine pause

Once we get back, we start tracking time again:

  1. hkredmine resume

But… we forgot what we were doing:

  1. hkredmine status
  2. hkredmine issue 154

OK, we’ve done as much as we can, we need some feedback to continue:

  1. hkredmine update 154 --status="Feedback"

Finally we’ll submit a time entry and watch the Issue:

  1. hkredmine stopwork --activity=Development comment="Fixed thing, waiting on confirmation."
  2. hkredmine watch 154

Contribute

Request features, report bugs and submit patches:
http://bugs.sleepanarchy.com/projects/hkredmine

A github mirror is available if you prefer pull requests:
https://github.com/prikhi/hkredmine

Use cabal to build the documentation:

  1. cabal haddock