Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

main.rs 795 B

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  1. mod cleaning;
  2. mod tsv;
  3. mod db;
  4. mod io;
  5. mod tracking;
  6. mod logging;
  7. mod commands;
  8. use anyhow::{anyhow, Result};
  9. use log::*;
  10. use structopt::StructOpt;
  11. use logging::LogOpts;
  12. use commands::*;
  13. /// BookData import tools
  14. #[derive(StructOpt, Debug)]
  15. #[structopt(name="bookdata")]
  16. struct Opt {
  17. #[structopt(flatten)]
  18. logging: LogOpts
  19. }
  20. fn main() -> Result<()> {
  21. let mut app = Opt::clap();
  22. let cmds = commands();
  23. for cmd in &cmds {
  24. app = app.subcommand(cmd.app().clone());
  25. }
  26. let matches = app.get_matches();
  27. let opt = Opt::from_clap(&matches);
  28. opt.logging.init()?;
  29. let (sc_name, sc_app) = matches.subcommand();
  30. debug!("subcommand name {}", sc_name);
  31. for cmd in &cmds {
  32. if cmd.name() == sc_name {
  33. cmd.run(sc_app.ok_or(anyhow!("no options"))?)?
  34. }
  35. }
  36. Ok(())
  37. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...