Giter VIP home page Giter VIP logo

combu's Introduction

combu

crates.io version license

combu is a customizable (or rather bare bones...?) cli framework. The library name "combu" comes from command + 昆布(konbu, it means kelp in japanese).

combu has no dependencies(or depends on only std library). Crate.io's page is here.

combu(com + 昆布)は柔軟に CLI を組み上げられることを目標とした、カスタマイズ可能(というより骨組みを組み上げてあるだけのような気もする)な CLI フレームワークです。 (一時クレートの名前が cmb だったこともありましたが、現在は combu です)

Features (特徴)

  • flag parsing in Unix format (Unix 形式でのフラグパース)
  • Nestable sub commmands (サブコマンド(多重可能))
  • No dependencies; combu depends on only std library (標準ライブラリ以外への依存ライブラリなし)
  • Typed flag: Bool, String, Int and Float, inspired from seahorse(seahorse を参考にした Bool, String, Int, Float の型つきフラグ)
  • common flag, local flag (コモンフラグ、ローカルフラグ両方を設定可能)
  • flag parsing before sub command args(サブコマンド前のフラグの受付)
  • 独自でパース等を行いたい場合に再利用できそうな構造体の設定
    • 似たような CLI フレームワークを作りたいときに使用できる部品を用意
  • Useful presets (コマンド、フラグ等のプリセット)
  • Return the result of run as Result<ActionResult, ActionError> (実行結果を Result に込めて実行後返却)

Documentation

Here

Installation to your project (プロジェクトでの使用方法)

Combu exists on crates.io. You can use(or import) this crate like other crate that exists on crates.io.

combu は crates.io に登録してありますので、他の crates.io 上のクレートと同じように使用(インポート)することが可能です。

Edit cargo.toml manually (手動での cargo.toml への追加)

Add

combu="[version you want to use]"

to cargo.toml.

上記コードでバージョンを指定して、cargo.toml に追加してください。

Use cargo-edit (Recommended) (cargo-edit でプロジェクトに追加する(推奨))

If you installed cargo-edit, exec below command under the target project:

cargo add combu

cargo-edit をインストールしてある場合は、上記のコマンドを実行することで使用可能です。

Quick Start

use combu::command::presets::func::help_tablize_with_alias_dedup;
use combu::{action_result, check_error, check_help, done, preset_root, Command};
use combu::{Context, Flag};
use std::env;

fn main() {
	let _r = preset_root!(act)
		.usage(env!("CARGO_PKG_NAME").to_string() + " [args]")
		.common_flag(
			Flag::new_bool("help")
				.short_alias('h')
				.description("show help"),
		)
		.local_flag(
			Flag::new_bool("local")
				.short_alias('l')
				.description("local flag"),
		)
		.run_from_args(env::args().collect());
}

fn act(cmd: Command, c: Context) -> action_result!()
{
	check_error!(cmd, c);
	check_help!(cmd, c, help_tablize_with_alias_dedup);
	println!("Hello, combu - {:?}", c.args);

	done!()
}

If you want to run quick start as example, exec

cargo run --example quick_start
cargo run --example quick_start --help

More detail: See quick_start.rs

Example

Inspired

TODO(or Features to be implemented)

  • ドキュメントコメントを分かりやすくする(いつになるかは無期限未定)
  • 必要そうなテストの実装(command.rsは済んでいる、完了は無期限未定)
  • コマンド構築にあたってのプリセット実装(主だったプリセット実装は済んでいるが、追加の可能性あり)

CONTRIBUTING

If you want to contribute combu, please read CONTRIBUTING.md for checking our code of conduct, and submitting pull requests to us.

Author(s?)

suquiya.

README Contribute: ksk001100 contributed on this pull request.

License

This is licensed under MIT LICENSE

Information about construct for this README.md

This readme is mainly based on seahorse's readme - Copyright (c) 2019 Keisuke Toyota - licensed MIT License.

combu's People

Contributors

suquiya avatar merlindiavova avatar

Stargazers

Price Smith avatar Song Liu avatar Andrew Prentice avatar DustInDark avatar Ashton Redd avatar dominic avatar Noel Towa avatar  avatar Rinrin.rs avatar tg-z avatar Kota Amasaka avatar  avatar Keisuke Toyota avatar

Watchers

James Cloos avatar Keisuke Toyota avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.