rust-practice / cargo-leet

Program to make working on leetcode problems locally more convenient
Apache License 2.0
5 stars 3 forks source link

cargo-leet - A leetcode local development assistant

A program that given the link or slug to a leetcode problem, creates a local file where you can develop and test your solution before post it back to leetcode.

Help Messages

cargo leet -h

cargo-leet

Usage: cargo <COMMAND>

Commands:
  leet  This is necessary because it's a cargo subcommand so the first argument needs to be the command name
  help  Print this message or the help of the given subcommand(s)

Options:
  -h, --help  Print help (see more with '--help')

cargo leet generate --help

Usage: cargo leet {generate|-g} [OPTIONS] [PROBLEM]

Arguments:
  [PROBLEM]
          Question slug or url (If none specified then daily challenge is used)

Options:
  -n, --number_in_name
          If set the module name generated includes the number for the problem

  -p, --path <FOLDER>
          Specify the path to the project root (If not provided uses current working directory)

  -l, --log-level <LOG_LEVEL>
          Set logging level to use

          [default: warn]

          Possible values:
          - off:   Nothing emitted in this mode
          - error
          - warn
          - info
          - debug
          - trace

  -h, --help
          Print help (see a summary with '-h')

Using Library Support

Using the library to "mimic" leetcode environment. Add library as a dependency as below. Then add use statements as necessary. The use statements are automatically added if tool is used to generate the file for the problem.

cargo-leet = "0.2.0"

Tool Installation

NB: If cargo-leet is already installed, and you install it again, it will just replace it even if it was previously installed from a different source. For example if you install it from a clone then run the command to install from git it will replace the existing version that is installed (they will not both be installed).

From GitHub

cargo install --git https://github.com/rust-practice/cargo-leet.git --branch main --features=tool

From Clone

After cloning the repo run

cargo install --path . --features=tool

or using alias from .cargo/config.toml

cargo i

Running Directly from source without install (When developing the tool)

These commands allow you to run the tool directly from the source code without installation. By default, they will run the tool on the current working directory. This means that it will run in the current project folder for cargo-leet. This may be fine for testing but if you want to be able to actually run the code, it might be more appropriate to pass the path parameter and specify the path to the repository you want to run against. Eg. cargo g --path $TEST_REPO For more options see generate help

cargo run --features=tool -- leet gen

or using alias from .cargo/config.toml

cargo g

Tool Uninstallation

cargo uninstall cargo-leet

License

All code in this repository is dual-licensed under either:

at your option. This means you can select the license you prefer! This dual-licensing approach is the de-facto standard in the Rust ecosystem and there are very good reasons to include both as noted in this issue on Bevy's repo.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.