| use std::{ |
| net::IpAddr, |
| path::{Path, PathBuf}, |
| }; |
|
|
| use clap::{Args, Parser, ValueEnum}; |
| use serde::{Deserialize, Serialize}; |
| use turbo_tasks::{NonLocalValue, TaskInput, trace::TraceRawVcs}; |
| use turbopack_cli_utils::issue::IssueSeverityCliOption; |
|
|
| #[derive(Debug, Parser)] |
| #[clap(author, version, about, long_about = None)] |
| pub enum Arguments { |
| Build(BuildArguments), |
| Dev(DevArguments), |
| } |
|
|
| impl Arguments { |
| |
| pub fn dir(&self) -> Option<&Path> { |
| match self { |
| Arguments::Build(args) => args.common.dir.as_deref(), |
| Arguments::Dev(args) => args.common.dir.as_deref(), |
| } |
| } |
| } |
|
|
| #[derive( |
| Copy, |
| Clone, |
| Debug, |
| ValueEnum, |
| PartialEq, |
| Eq, |
| Serialize, |
| Deserialize, |
| Hash, |
| TaskInput, |
| NonLocalValue, |
| TraceRawVcs, |
| )] |
| pub enum Target { |
| Browser, |
| Node, |
| } |
|
|
| #[derive(Debug, Args, Clone)] |
| pub struct CommonArguments { |
| |
| |
| #[clap(value_parser)] |
| pub entries: Option<Vec<String>>, |
|
|
| |
| |
| #[clap(short, long, value_parser)] |
| pub dir: Option<PathBuf>, |
|
|
| |
| |
| |
| #[clap(long, value_parser)] |
| pub root: Option<PathBuf>, |
|
|
| |
| #[clap(short, long)] |
| pub log_level: Option<IssueSeverityCliOption>, |
|
|
| |
| #[clap(long)] |
| pub show_all: bool, |
|
|
| |
| #[clap(long)] |
| pub log_detail: bool, |
|
|
| |
| #[clap(long)] |
| pub full_stats: bool, |
|
|
| |
| |
| |
| |
| |
| #[clap(long)] |
| pub target: Option<Target>, |
| } |
|
|
| #[derive(Debug, Args)] |
| #[clap(author, version, about, long_about = None)] |
| pub struct DevArguments { |
| #[clap(flatten)] |
| pub common: CommonArguments, |
|
|
| |
| |
| |
| |
| #[clap(short, long, value_parser, default_value_t = 3000, env = "PORT")] |
| pub port: u16, |
|
|
| |
| #[clap(short = 'H', long, value_parser, default_value = "0.0.0.0")] |
| pub hostname: IpAddr, |
|
|
| |
| |
| #[clap(long)] |
| pub eager_compile: bool, |
|
|
| |
| #[clap(long)] |
| pub no_open: bool, |
|
|
| |
| |
| |
| |
| |
| #[clap(long)] |
| pub allow_retry: bool, |
| } |
|
|
| #[derive(Debug, Args)] |
| #[clap(author, version, about, long_about = None)] |
| pub struct BuildArguments { |
| #[clap(flatten)] |
| pub common: CommonArguments, |
|
|
| |
| #[clap(long)] |
| pub no_sourcemap: bool, |
|
|
| |
| #[clap(long)] |
| pub no_minify: bool, |
|
|
| |
| #[clap(long)] |
| pub no_scope_hoist: bool, |
|
|
| |
| |
| |
| #[clap(long, hide = true)] |
| pub force_memory_cleanup: bool, |
| } |
|
|