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
use crate::{code_generator::CodeGenerator, error::Result, php, rust, FileCreator}; use structopt::StructOpt; /** Holds the main configuration for Transporter and builds generated code accordingly using [CodeGenerator::build](trait.CodeGenerator.html#tymethod.build). Use `Cli::from_args()` to parse command line arguments. Then use [CodeGenerator::build](trait.CodeGenerator.html#tymethod.build) to build the code for the language specified by the subcommand. ``` use transporter::Cli; use structopt::StructOpt; let cli = Cli::from_iter(vec!["transporter", "rust", "src/Api"]); match cli { Cli::Rust(_) => println!("Running the \"rust\"-subcommand"), _ => unreachable!(), } ``` */ #[derive(StructOpt)] pub enum Cli { Rust(rust::Cli), Php(php::Cli), } impl CodeGenerator for Cli { fn build<C>(&self, fc: &mut C) -> Result<()> where C: FileCreator, { match self { Self::Rust(cli) => cli.build(fc), Self::Php(cli) => cli.build(fc), } } }