# Kyopuro

This package provides a mix of tasks for AtCoder and YukiCoder. This package provides mix tasks for module generation and test case generation.



## Installation

The Meeseeks package used in this package uses Rust for Nifs, so you need to set up the Rust environment beforehand.


def deps do
    {:kyopuro, "~> 0.4.0"}


## Usage - 使い方

現在 [AtCoder]( と [YukiCoder]( に対応しています。

## AtCoder

### Login - ログイン

First, run the `mix kyopuro.login`.

最初に`mix kyopuro.login`を実行します。

    $ mix kyopuro.login [--username USERNAME] [--password PASSWORD] [--interactive]

By default, use `Application.fetch_env` to read the login information. Write a configuration in `config.exs` and so on.


# in config/config.exs
import Config

config :kyopuro,
    username: USERNAME,
    password: PASSWORD

You can use the `-i` or `--interactive` option to enable the interactive login.


You can use the `-u` or `--username` options to give a username as an argument.


You can use the `-p` or `--password` option to give the password as an argument.

If you get a 403 error, please try again.
### Generate module & test - モジュールとテストの生成

Once you have logged in, you can specify a contest to generate modules and tests.


    $ mix CONTEST_NAME
If you want to generate abc100 modules and tests, here's how it looks like.


    $ mix abc100

In this case, the modules and tests will be generated as follows (if you run it in a hoge project)


 ┬ lib ─ hoge ─ abc100 ─ ┬ a.ex
 │                       ├ b.ex
 │                       ├ c.ex
 │                       └ d.ex
 └ test ─ hoge_test ─ abc100 ┬ a_test.exs
                             ├ b_test.exs
                             ├ c_test.exs
                             └ d_test.exs

### Running Tests - テストの実行

The `mix test` is used to run the test.

テストを実行するには`mix test`を使用します。

### Submit - 提出

You can submit a contest name or the name of the contest and task.


    $ mix kyopuro.submit CONTEST_NAME
    $ mix kyopuro.submit CONTEST_NAME TASK_NAME

If you want to generate abc100 modules and tests, this is how it looks like.


    $ mix kyopuro.submit abc100
    $ mix kyopuro.submit abc100 a

You can give multiple task names.


    $ mix kyopuro.submit abc100 a b c d

### Template - テンプレート

You can customize the templates of the generated modules.


# in config/config.exs
import Config

config :kyopuro,
    module_template: "#{module_template_file_path}"

Only one value is currently available in the template.


|module|The module name is stored in|


Basically, extend the `priv/templates/at_coder/module.ex`


## YukiCoder

### Preparation - 準備


# in config/config.exs
import Config

config :kyopuro,
    api_key: API_KEY,
    adapter: Kyopuro.YukiCoder

### Generate module & test - モジュールとテストの生成


    $ mix [--contest CONTEST_ID] [--problem PROBLEM_NO]


### Running Tests - テストの実行


### Submit - 提出

    $ mix kyopuro.submit [--contest CONTEST_ID] [--problem PROBLEM_ID]

### Template - テンプレート



## Other - その他

### File name rewriting - ファイル名の書き換え

If you have rewritten the file name, edit `.mapping.json`.


The `.mapping.json` file contains the contest name, task name and file path. Since this file is referenced at the time of submission, it will not work properly if the module file name is rewritten.


## Future - 今後の予定

- Minor update
    - 他のサイト(AOJとか)に対応する
    - 提出前にテストを実行して、失敗した場合は確認するようにする
- Patch update
    - バグ修正