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

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

Comments

Loading...