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

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

Comments

Loading...