mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
Added homepage for website, fixes #2478
This commit is contained in:
parent
278d17048f
commit
54dffec127
4 changed files with 72 additions and 1 deletions
|
@ -5,7 +5,7 @@ description = "Fast & Modern CLI Framework for Rust"
|
|||
|
||||
compile_sass = false
|
||||
highlight_code = true
|
||||
highlight_theme = "material-light"
|
||||
highlight_theme = "ayu-dark"
|
||||
build_search_index = true
|
||||
|
||||
default_language = "en"
|
||||
|
|
|
@ -1,3 +1,60 @@
|
|||
+++
|
||||
title = "Fast & Modern CLI Framework for Rust"
|
||||
+++
|
||||
|
||||
**Clap** is a simple-to-use, efficient, and full-featured library for parsing command line arguments and subcommands when writing console/terminal applications.
|
||||
|
||||
Here is an example of a simple program:
|
||||
|
||||
```rust
|
||||
use clap::Clap;
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Clap, Debug)]
|
||||
#[clap(name = "hello")]
|
||||
struct Hello {
|
||||
/// Name of the person to greet
|
||||
#[clap(short, long)]
|
||||
name: String,
|
||||
|
||||
/// Number of times to greet
|
||||
#[clap(short, long, default_value = "1")]
|
||||
count: u8,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let hello = Hello::parse();
|
||||
|
||||
for _ in 0..hello.count {
|
||||
println!("Hello {}!", hello.name)
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The above example program can be run as shown below:
|
||||
|
||||
```
|
||||
$ hello --name John --count 3
|
||||
Hello John!
|
||||
Hello John!
|
||||
Hello John!
|
||||
```
|
||||
|
||||
The program also has automatically generated help message:
|
||||
|
||||
```
|
||||
hello
|
||||
|
||||
Simple program to greet a person
|
||||
|
||||
USAGE:
|
||||
hello [OPTIONS] --name <name>
|
||||
|
||||
FLAGS:
|
||||
-h, --help Prints help information
|
||||
-V, --version Prints version information
|
||||
|
||||
OPTIONS:
|
||||
-c, --count <count> Number of times to greet [default: 1]
|
||||
-n, --name <name> Name of the person to greet
|
||||
```
|
||||
|
|
|
@ -116,6 +116,14 @@ footer a, #content a {
|
|||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
pre {
|
||||
font-family: 'Raleway', monospace;
|
||||
font-size: 0.9rem;
|
||||
line-height: 1.2rem;
|
||||
padding: 1.5rem;
|
||||
margin-bottom: 30px;
|
||||
}
|
||||
|
||||
@media (max-width: 767px) {
|
||||
#content {
|
||||
padding: 1.25rem 0.5rem 3rem;
|
||||
|
@ -136,6 +144,7 @@ p {
|
|||
h1, h2, h3, h4 {
|
||||
margin-bottom: 20px;
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: rgb(255, 168, 106);
|
||||
}
|
||||
|
||||
h1 {
|
||||
|
|
|
@ -6,5 +6,10 @@
|
|||
{% include "shared/header.html" %}
|
||||
|
||||
<main id="content" class="maxview">
|
||||
<article>
|
||||
<h1 class="post-title">{{ section.title }}</h1>
|
||||
|
||||
{{ section.content | safe }}
|
||||
</article>
|
||||
</main>
|
||||
{% endblock content %}
|
||||
|
|
Loading…
Reference in a new issue