cli min
This commit is contained in:
parent
d18f0b630d
commit
0d94de70e1
14
ref/cli/.gitignore
vendored
Normal file
14
ref/cli/.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
/target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# IDEs
|
||||
.vscode/
|
||||
.idea/
|
||||
15
ref/cli/Cargo.toml
Normal file
15
ref/cli/Cargo.toml
Normal file
@ -0,0 +1,15 @@
|
||||
[package]
|
||||
name = "cli"
|
||||
version = "0.1.0"
|
||||
authors = ["lovebird <cgoflyn@gmail.com>"]
|
||||
edition = "2018"
|
||||
license-file = "LICENSE-MIT.md"
|
||||
readme = "README.md"
|
||||
|
||||
[dependencies]
|
||||
clap = "2.33.0"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 'z'
|
||||
lto = true
|
||||
panic = 'abort'
|
||||
21
ref/cli/LICENSE-MIT.md
Normal file
21
ref/cli/LICENSE-MIT.md
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2020 lovebird <cgoflyn@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
12
ref/cli/README.md
Normal file
12
ref/cli/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
# Rust cli boilerplate.
|
||||
|
||||
Contains [clap](https://clap.rs/) for arguments parsing and nothing else.
|
||||
|
||||
# How to use this boilerplate?
|
||||
|
||||
- Replace name, authors etc in [Cargo.toml](./Cargo.toml) and you are good to go.
|
||||
|
||||
- Using cargo [generate](https://github.com/ashleygwilliams/cargo-generate).
|
||||
```sh
|
||||
cargo generate --git https://github.com/pjmp/rust-cli-boilerplate.git
|
||||
```
|
||||
21
ref/cli/src/cli.rs
Normal file
21
ref/cli/src/cli.rs
Normal file
@ -0,0 +1,21 @@
|
||||
use clap::{
|
||||
crate_authors, /* , Arg */
|
||||
crate_description, crate_name, crate_version, App, AppSettings,
|
||||
};
|
||||
|
||||
pub fn new() -> App<'static, 'static> {
|
||||
App::new(crate_name!())
|
||||
.version(crate_version!())
|
||||
.about(crate_description!())
|
||||
.author(crate_authors!())
|
||||
.setting(AppSettings::ArgRequiredElseHelp)
|
||||
.setting(AppSettings::ColorAuto)
|
||||
// .arg(
|
||||
// Arg::with_name("option")
|
||||
// .short("o")
|
||||
// .long("option")
|
||||
// .help("option description")
|
||||
// .takes_value(true)
|
||||
// .value_name("opts"),
|
||||
// )
|
||||
}
|
||||
5
ref/cli/src/main.rs
Normal file
5
ref/cli/src/main.rs
Normal file
@ -0,0 +1,5 @@
|
||||
mod cli;
|
||||
|
||||
fn main() {
|
||||
let _app = cli::new().get_matches();
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user