LoginSignup
11
10

More than 5 years have passed since last update.

Heroku CLI に hk を使う。

Last updated at Posted at 2014-08-23

hkとは

Herokuをコマンドラインから操作するためのツールで、Heroku Toolbeltよりも高速っぽいです。

(Goで実装されている ※ beta版)

インストール

$ L=/usr/local/bin/hk && curl -sL -A "`uname -sp`" https://hk.heroku.com/hk.gz | zcat >$L && chmod +x $L

めずらしい配布方法だなぁと思いつつ、これですんなりインストールできます。

Go言語ではクロスコンパイルがとても簡単で,複数プラットフォーム向けのバイナリをつくってそれを配布するというのがさらっとできる.

とのことで、HerokuとGithubを使った統一的なツール配布 でとてもわかりやすく解説されています。

使い方

$ hk -h
Usage: hk <command> [-a <app or remote>] [options] [arguments]


Commands:

    create             create an app
    apps               list apps
    dynos              list dynos
    releases           list releases
    release-info       show release info
    rollback           roll back to a previous release
    addons             list addons
    addon-add          add an addon
    addon-destroy      destroy an addon
    scale              change dyno quantities and sizes
    restart            restart dynos
    set                set env var
    unset              unset env var
    env                list env vars
    run                run a process in a dyno
    log                stream app log lines
    info               show app info
    rename             rename an app
    destroy            destroy an app
    domains            list domains
    domain-add         add a domain
    domain-remove      remove a domain
    version            show hk version
    orgs               list Heroku orgs
    ssl                show ssl endpoint info
    ssl-cert-add       add a new ssl cert
    ssl-cert-rollback  add a new ssl cert
    ssl-destroy        destroy ssl endpoint


Run 'hk help [command]' for details.


Additional help topics:

    commands  list all commands with usage
    environ   environment variables used by hk
    plugins   interface to plugin commands
    more      additional commands, less frequently used
    about     information about hk (e.g. copyright, license, etc.)

大抵のことできそうです。

どんくらい速いのか

公式のとこにもあるけど、自分の環境でも計測してみます。

$ time heroku apps >/dev/null
heroku apps > /dev/null  1.24s user 0.12s system 25% cpu 5.255 total

$ time hk apps >/dev/null
hk apps > /dev/null  0.09s user 0.02s system 10% cpu 1.088 total

速い!

golang興味あるので、この機会にやってみたい。

追記

hk (Go) で書かれていたものは、Heroku CLI(v4) で正式に採用(一部Node.js)されたが、ネットワークやクロスコンパイルなどの問題で、今(CLI v6)は Pure Node.js で実装されている。

参考・引用

11
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
10