main.rs 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. mod build_ebpf;
  2. mod build;
  3. mod run;
  4. mod codegen;
  5. mod filter;
  6. use std::process::exit;
  7. use clap::Parser;
  8. use env_logger::Env;
  9. #[derive(Debug, Parser)]
  10. pub struct Options {
  11. #[clap(subcommand)]
  12. command: Command,
  13. }
  14. #[derive(Debug, Parser)]
  15. enum Command {
  16. BuildEbpf(build_ebpf::Options),
  17. BuildArtifacts(build::Options),
  18. BuildFilterFile(filter::Options),
  19. Run(run::Options),
  20. CodeGen,
  21. }
  22. fn main() {
  23. env_logger::Builder::from_env(Env::default().default_filter_or("info")).init();
  24. let opts = Options::parse();
  25. use Command::*;
  26. let ret = match opts.command {
  27. BuildEbpf(opts) => build_ebpf::build_ebpf(opts),
  28. BuildArtifacts(opts) => build::build(opts),
  29. Run(opts) => run::run(opts),
  30. CodeGen => codegen::generate(),
  31. BuildFilterFile(opts) => filter::build_filter(opts),
  32. };
  33. if let Err(e) = ret {
  34. eprintln!("{:#}", e);
  35. exit(1);
  36. }
  37. }