mirror of
https://codeberg.org/JasterV/Image-Processing-CLI.git
synced 2026-04-26 18:10:07 +00:00
Simple Clap CLI Implementation
Added clap as a dependency to built the CLI in order to test the image crate through a simple to use command
This commit is contained in:
parent
9011440afe
commit
49c915ef6b
8 changed files with 61 additions and 0 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -8,3 +8,8 @@ Cargo.lock
|
|||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
|
|
|
|||
14
Cargo.toml
Normal file
14
Cargo.toml
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
[package]
|
||||
name = "imgffs"
|
||||
version = "0.1.0"
|
||||
authors = ["Víctor Martínez <victorcoder2@gmail.com>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
name = "lib"
|
||||
|
||||
[dependencies]
|
||||
image = "0.23.12"
|
||||
clap = "2.33.3"
|
||||
BIN
mock/beach.jpg
Normal file
BIN
mock/beach.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
BIN
mock/chair.jpg
Normal file
BIN
mock/chair.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
BIN
mock/tree.png
Normal file
BIN
mock/tree.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 MiB |
28
src/cli/mod.rs
Normal file
28
src/cli/mod.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
use clap::{App, Arg};
|
||||
|
||||
const HELP_TEMPLATE: &str = "{bin} v{version}
|
||||
|
||||
-----------
|
||||
|
||||
{about}
|
||||
|
||||
{all-args}
|
||||
|
||||
-----------
|
||||
|
||||
(C) 2020 {author}
|
||||
|
||||
{after-help}";
|
||||
|
||||
/// This function builds the Command Line Application
|
||||
/// already with its metadata, args boundaries etc.
|
||||
pub fn build_cli() -> App<'static, 'static> {
|
||||
App::new("Image Editor application")
|
||||
.author(crate_authors!())
|
||||
.version(crate_version!())
|
||||
.about("Edit, transform, crop, rotate etc. an image with just one command")
|
||||
.template(HELP_TEMPLATE)
|
||||
.before_help("Thanks for using this app bro :)")
|
||||
.after_help("Have a nice day!")
|
||||
.arg(Arg::with_name("FILE").index(1).required(true))
|
||||
}
|
||||
4
src/lib.rs
Normal file
4
src/lib.rs
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
#[macro_use]
|
||||
extern crate clap;
|
||||
|
||||
pub mod cli;
|
||||
10
src/main.rs
Normal file
10
src/main.rs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
extern crate clap;
|
||||
extern crate image;
|
||||
|
||||
use lib::cli;
|
||||
|
||||
fn main() {
|
||||
let matches = cli::build_cli().get_matches();
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in a new issue