はじめに Qiitaのコメントで、紹介してもらったclickを調べてみたら、簡単にサブコマンドを実装できることが分かったので、そのやり方をまとめておく。サブコマンドとは、スクリプトの第一引数が、コマンドになっているような形態のコマンドで、git, svnなどのバージョン管理コマンドや、djangoのプロジェクト管理スクリプトmanage.pyなどにみられる形式だ。 環境構築 clickは、pythonの標準パッケージではないので、pipでインストールする。 import click @click.group(invoke_without_command=True) @click.pass_context def cli(ctx): if ctx.invoked_subcommand is None: print ctx.get_help() else: print('gonna invok
Python のコマンドラインパーサといえば、標準ライブラリに組み込まれている argparse が基本。 蛇足になるけど、バージョン 2.7 以前で使われていた optparse は将来的に廃止予定なので新たに使うことは避けた方が良い。 そして、今回紹介する Python のサードパーティ製コマンドラインパーサ Click は、既存のパッケージと比較すると最小限のコードで美しくコマンドラインインターフェースを実装できるように作られている。 どれくらい楽になるかといえば、もう argparse を使っている場合じゃないな、と思えるレベル。 Welcome to Click — Click Documentation (8.0.x) もくじ もくじ Click をインストールする 基本的な使い方 コマンドを定義する オプションを追加する 引数を追加する サブコマンドを作る オプションについて
This table has the number of command line options for various commands for v7 Unix (1979), slackware 3.1 (1996), ubuntu 12 (2015), and ubuntu 17 (2017). Cells are darker and blue-er when they have more options (log scale) and are greyed out if no command was found. We can see that the number of command line options has dramatically increased over time; entries tend to get darker going to the right
Jupyter notebookはとても便利な一方,どうしてもWeb UIを経由して操作する必要があります.標準のUIは使いやすいですが,使っていくと,Editorのカラースキームやキーバインディングなどが自由にできなかったりと微妙な不満が出てきます. 本記事では,黒い画面が好きな人向けの,Jupyter環境を整備する手順と,その構築に必要なプラグインをご紹介します. あらましJupyter〜〜〜??そんなんIPythonにWebインターフェースつけただけやろ〜〜〜???と思ってなんとなく抵抗感を感じているいる人も多いと思います.しかし一度使ってみると非常に便利で,特に画像的な出力を連発しながらデータを探索的に解析していくとき非常に大きな力を発揮します.Matplotlibとかgnuplotとかを駆使して,出力された画像をいちいちダウンロードして確認するのは骨が折れますよね….. しかし,
Slackはそのクライアントがそれなりに、かなりよくできていて、これでほとんど困ることはないんだけど、そうは言ってももうちょっとプログラマブルに取り扱いたいこともある。 そういう場合にもよいAPIが用意されていて、Real Time Messaging API ってのがある。こいつはWebSocketでSlackの発言をはじめ、あらゆるイベントのJSONを送りつけてくれるやつ。ひとまずこれを標準出力に流すことができれば、あとは好きに料理できるはずだ。 というわけで作ったのがこちら。書いたことなかったのでRustです。ちょうどいいネタだった。 GitHub - motemen/slack-stream-json slack-stream-json というバイナリが、SLACK_TOKEN 環境変数を設定した上で起動してやると、RTM APIによって得られたイベントのJSONをそのまま標準出力
One of the great parts of the hacker culture 1 and the GNU way is the invention 2 of pipes and the idea 3 that one program should do one thing and do it well. Each running program (process) has one input stream (called standard input or STDIN) and one output stream (called standard output or STDOUT) and also one additional output stream for logging/errors/warnings (STDERR). We can connect programs
CSV, TSV, and other delimiter-separated value formats. Tools belong on this list if they support field quoting. csv-nix-tools — List *nix system information such as environment variables, files, processes, network connections, users as CSV. Manipulate and pretty-print CSV. Execute CSV rows as commands. csv2html — Convert CSV to HTML tables. csv2md — Convert CSV to Markdown tables. csvfaker — Gener
Today we are happy to announce the launch of LiteCLI! LiteCLI is a user-friendly CommandLine client for SQLite database. It is based on the popular pgcli and mycli projects. LiteCLI is written in python using the wonderful prompt-toolkit library. It is cross-platform compatible and it is tested on Linux, MacOS and Windows. It is developed by a team of core devs from around the world. We are friend
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く