Skip to content

Commit ab891b1

Browse files
committed
Update structopt example to use clap
1 parent fc6e3ca commit ab891b1

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
use clap::Parser;
2+
13
/// Read some lines of a file
2-
#[derive(Debug, StructOpt)]
4+
#[derive(Debug, Parser)]
35
struct Cli {
46
/// Input file to read
57
file: String,
68
/// Number of lines to read
7-
#[structopt(short = "n")]
9+
#[structopt(short = 'n')]
810
num: usize,
911
}

templates/components/what/cli/code-main.html.hbs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
use quicli::prelude::*;
2-
use structopt::StructOpt;
1+
use std::{error::Error, fs::read_to_string};
32

4-
fn main() -> CliResult {
5-
let args = Cli::from_args();
6-
read_file(&args.file)?
3+
fn main() -> Result<(), Box<dyn Error>> {
4+
let args = Cli::parse();
5+
read_to_string(&args.file)?
76
.lines()
87
.take(args.num)
98
.for_each(|line| println!("{}", line));

0 commit comments

Comments
 (0)