Skip to content

Commit

Permalink
Merge pull request #38 from rust-transit/switch_to_clap
Browse files Browse the repository at this point in the history
Switch from docopt to clap
  • Loading branch information
Tristramg authored Jan 26, 2024
2 parents 648195a + a94b47f commit 34be0f5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = "MIT"
[dependencies]
osmpbfreader = "0.16.1"
csv = "1.3.0"
docopt = "1.1.1"
clap = { version = "4.4", features = ["derive"] }
serde = "1.0"

[lib]
Expand Down
18 changes: 10 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
use clap::Parser;

#[derive(Parser)]
#[command(author, version, about, long_about = None)]
struct Cli {
source_pbf: String,
}
fn main() {
const USAGE: &str = "
Usage: osm4routing <source.osm.pbf>";
let args = docopt::Docopt::new(USAGE)
.unwrap()
.parse()
.unwrap_or_else(|e| e.exit());
let filename = args.get_str("<source.osm.pbf>");
match osm4routing::read(filename) {
let cli = Cli::parse();

match osm4routing::read(&cli.source_pbf) {
Ok((nodes, edges)) => osm4routing::writers::csv(nodes, edges),
Err(error) => println!("Error: {}", error),
}
Expand Down

0 comments on commit 34be0f5

Please sign in to comment.