LoginSignup
9
3

More than 3 years have passed since last update.

AOJ 用のコマンドライン CLI ツールを作った

Posted at

ちょっと前に Aizu Online Judge (AOJ) のための CLI ツールを作成したので記事を書いてみようと思う

作成したものはこれ: https://github.com/travelist/aoj-cli

機能は限りなくシンプルで、以下のことができる:

  • 問題文のテストケースを含むディレクトリ作成
  • テストの実行
  • 提出

animation (1).gif

導入方法

バイナリーならば ここ からダウンロードでき、Mac ならば homebrew を使って以下のコマンドでインストールできる:

brew tap travelist/homebrew-aoj-cli
brew install aoj

本題とは関係ないけれども、CLI ツールを作って配布するのに Go が便利だと感じた。
バイナリーとして配布できるので、他人のPCの実行環境(例えば Python のバージョンなど)を気にしなくてよいのは大きなメリットだと思う。

AOJ CLI の設定 (初回のみ実行)

aoj init

テストサンプルのダウンロードとディレクトリの作成

aoj gen [PROBLEM-ID]

ソースコードのテスト

# cd ./[PROBLEM-ID]
aoj test

ソースコードの提出

aoj submit

その他設定

デフォルトの設定ファイル: ~/.aoj-cli/config.toml
デフォルトのテンプレートファイル: ~/.aoj-cli/template.txt

[gen]
template_file = "$HOME/.aoj-cli/template.txt"
destination_file_name = "main.cpp"

[test]
before_all="g++ main.cpp -o a.out"
before_each=""
command="a.out"
after_each=""
after_all=""

[submit]
language = "C++"
source_file_name = "main.cpp"
parameter description
gen.template_file テンプレートファイルへのパス
gen.destination_file_name 生成するコードのファイル名
test.before_all テスト全体の前に実行するコマンド
test.before_each 各テスト前に実行するコマンド
test.test_commands テストで実行するコマンド
test.after_each 各テスト後に実行するコマンド
test.after_all すべてのテスト後に実行するコマンド
submit.language 提出するプログラムの言語 ex: JAVA, C++
submit.source_file_name 提出時するファイル名

最後に

もしよければ使ってみてもらえたらと思います m(__)m

9
3
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
9
3