Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

V3.0.0 Rewrite #9

Closed
wants to merge 43 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
b8bb13b
Start of rewrite
Owez Sep 21, 2020
17976c2
Added basic arg impls
Owez Sep 21, 2020
ba0e1d4
Added boilerplate broad_help and specific_help to Argument
Owez Sep 21, 2020
208b9b8
Added todo comment for argument docstring
Owez Sep 21, 2020
7debb99
Bumped cargo version up to 3.0.0-pre.1 for future prerelease
Owez Sep 21, 2020
b7b8908
Added help_combinations test & fixed func
Owez Sep 23, 2020
73a8b0a
More docs and new docstring for [AllowedData]
Owez Sep 24, 2020
92a809c
Start of rewrite
Owez Dec 15, 2020
c68074c
Removed crate_version
Owez Dec 15, 2020
f58aed3
Added "to this root CliMake" to make subcommands more obvious
Owez Dec 15, 2020
53aa516
Fixed lifetimes
Owez Dec 16, 2020
4e04494
Renamed header_string and help_str to more uniform convention
Owez Dec 17, 2020
b334a0d
Added std::io::Write to gen_header_line
Owez Dec 17, 2020
7fdc912
Added Input enum
Owez Dec 17, 2020
d44416c
Added argument help
Owez Dec 17, 2020
c1c0ba3
Added full cli help_msg
Owez Dec 17, 2020
3f1bf50
Renamed `Options` to `Arguments`
Owez Dec 17, 2020
209429e
More checks to arg_full_help
Owez Dec 17, 2020
a780a6c
Added cli_help_print example
Owez Dec 17, 2020
c9d0889
Fixed tests, forgot to update
Owez Dec 17, 2020
578abd3
Added docs for help_msg and header_msg
Owez Dec 17, 2020
a4344da
Swapped name pos of CliMake
Owez Dec 17, 2020
6b99cd1
Started support for subcommands
Owez Dec 21, 2020
59030c7
Proper subcommand help
Owez Dec 21, 2020
78bb5f2
Fixed subcommand help from cli root
Owez Dec 22, 2020
29e2d7f
Fixed docstring help/tests
Owez Dec 22, 2020
b65753a
Formatted lib.rs
Owez Dec 22, 2020
5f68298
Nicer header_msg cur_exe
Owez Dec 22, 2020
6704dd5
Added subcommand name help test
Owez Dec 22, 2020
36b01fe
Added required argument help
Owez Dec 22, 2020
d8f234c
Made passed args to climake references
Owez Dec 22, 2020
c2cfa48
Made add_arg and add_args chainable
Owez Dec 24, 2020
c580427
Added docstring for lib & forbid unsafe code
Owez Dec 24, 2020
fb7d21e
Refractored
Owez Dec 24, 2020
abbf840
Reformatted examples
Owez Dec 24, 2020
7583026
Added add_subcmd and add_subcmds methods to CliMake
Owez Dec 24, 2020
0ca8e6d
Refractored add_subcmd(s)
Owez Dec 24, 2020
5e362c7
Added data enum
Owez Dec 24, 2020
f17c8cd
Added Data::new tests
Owez Dec 24, 2020
d48e71f
Added add_scall, add_scalls, add_lcall and add_lcalls to Argument
Owez Dec 24, 2020
56b84b5
Removed i.e. CallType arguments
Owez Dec 24, 2020
af26d94
Updated logo
Owez Dec 24, 2020
7afe616
Added README.md disclaimer
Owez Dec 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ description = "The simple, dependency-less cli library ✨"
repository = "https://github.com/rust-cli/climake"
readme = "README.md"
license = "MIT OR Apache-2.0"
version = "2.1.0"
version = "3.0.0-pre.1"
authors = ["Owez <root@ogriffiths.com>"]
edition = "2018"
37 changes: 10 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,27 @@
# climake
# climake

The simple, dependency-less cli library ✨
The simple, dependency-free cli library ✨

- [Crates.io](https://crates.io/crates/climake)
- [Documentation](https://docs.rs/climake)

---

This branch represents the unpublished rewrite version of climake with many advantages compared to the original version which is no longer updated!

---

## Example 📚

```rust
use climake::{Argument, CLIMake, DataType};

fn main() {
let args = &[
Argument::new(
&['o'],
&["output", "out"],
Some("Example output arg"),
DataType::Files,
).unwrap(),
Argument::new(
&['a', 'b', 'c'],
&[],
Some("Alphabet!"),
DataType::None,
).unwrap(),
];

let cli = CLIMake::new(args, Some("A showcase CLI to demonstrate climake"), None).unwrap();

println!("Args used: {:#?}", cli.parse());
}
```
Rewrite example coming soon!

## Installation 🚀

Simply add the following to your `Cargo.toml` file:

```toml
[dependencies]
climake = "2.1"
climake = "3.0" # note: rewrite isn't out just yet!
```

## License
Expand Down
44 changes: 44 additions & 0 deletions examples/header_showcase.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//! Example which simply prints header infomation. Please note that this does not
//! parse any cli infomation, but just simply prints out infomation about this cli

use climake::CliMake;
use std::io;

const DIVIDER: &str =
"--------------------------------------------------------------------------------";

fn main() -> io::Result<()> {
let mut stdout = io::stdout();

println!("Simple:\n{}", DIVIDER);
CliMake::new(
"Example program",
vec![],
vec![],
"A simple description",
"1.0.0",
)
.header_msg(None, &mut stdout)?;

println!("{0}\n\nLong:\n{0}", DIVIDER);
CliMake::new(
"Example program",
vec![],
vec![],
"A very long description, designed to potentially span multiple lines to test the prowess of formatting climake uses",
"1.0.0"
).header_msg(None, &mut stdout)?;
println!("{}", DIVIDER);

println!("{0}\n\nSubcommand example:\n{0}", DIVIDER);
CliMake::new(
"Example program",
vec![],
vec![],
"This program contains the subcommand aptly named w/the `my_subcommand` command added onto this",
"1.0.0"
).header_msg("my_subcommand", &mut stdout)?;
println!("{}", DIVIDER);

Ok(())
}
11 changes: 11 additions & 0 deletions examples/help_empty.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//! Example of the most empty possible CLI you can make, to showcase edge case
//! handling in regards to help generation

use climake::CliMake;
use std::io;

fn main() -> io::Result<()> {
let cli = CliMake::new("my-cli", vec![], vec![], None, None);

cli.help_msg(&mut io::stdout())
}
30 changes: 30 additions & 0 deletions examples/help_print.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//! Example to show help generation in action. Please note that this does not
//! parse any cli infomation, but just simply prints out infomation about this cli

use climake::{Argument, CliMake, Input};
use std::io;

fn main() -> std::io::Result<()> {
let verbose = Argument::new(
"Toggles verbose mode",
vec!['v'],
vec!["verbose"],
Input::None,
);
let debug = Argument::new(
"Toggles debug infomation",
vec!['d'],
vec!["debug"],
Input::None,
);

let cli = CliMake::new(
"Help info",
vec![&verbose, &debug],
vec![],
"A simple utility cli to print help info",
"1.0.0",
);

cli.help_msg(&mut io::stdout())
}
40 changes: 40 additions & 0 deletions examples/help_subcommand.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
//! Example showing a demonstration subcommand utilising help generation for itself
//! with semi-complex recursion/duplication of subcommands

use climake::{CliMake, Subcommand};
use std::io;

fn main() -> io::Result<()> {
let subcmd_img = Subcommand::new("img", vec![], vec![], "An image");
let subcmd_text = Subcommand::new("text", vec![], vec![], "Textual input");

let subcmd_add = Subcommand::new(
"add",
vec![],
vec![&subcmd_img, &subcmd_text],
"Adds a new post",
);
let subcmd_rem = Subcommand::new(
"rem",
vec![],
vec![&subcmd_img, &subcmd_text],
"Removes an existing post",
);

let cli = CliMake::new(
"subcommandsgalore",
vec![],
vec![&subcmd_add, &subcmd_rem],
"A demonstration cli to show subcommand help",
None,
);

println!("Help message overall:\n----");
cli.help_msg(&mut io::stdout())?;
println!("----\nAdd subcommand help message:\n----");
subcmd_add.help_msg(&cli, &mut io::stdout())?;
println!("----\nRemove subcommand help message:\n----");
subcmd_rem.help_msg(&cli, &mut io::stdout())?;

Ok(())
}
22 changes: 0 additions & 22 deletions examples/readme_showcase.rs

This file was deleted.

Binary file modified logo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 13 additions & 56 deletions logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.