jxl_oxide_cli/
commands.rs

1pub mod color_encoding;
2pub mod decode;
3#[cfg(feature = "__devtools")]
4pub mod dump_jbrd;
5#[cfg(feature = "__devtools")]
6pub mod generate_fixture;
7pub mod info;
8#[cfg(feature = "__devtools")]
9pub mod progressive;
10#[cfg(feature = "__ffmpeg")]
11pub mod slow_motion;
12#[cfg(test)]
13pub mod tests;
14
15pub use color_encoding::parse_color_encoding;
16pub use decode::DecodeArgs;
17#[cfg(feature = "__devtools")]
18pub use dump_jbrd::DumpJbrd;
19#[cfg(feature = "__devtools")]
20pub use generate_fixture::GenerateFixtureArgs;
21pub use info::InfoArgs;
22#[cfg(feature = "__devtools")]
23pub use progressive::ProgressiveArgs;
24#[cfg(feature = "__ffmpeg")]
25pub use slow_motion::SlowMotionArgs;
26
27#[derive(Debug, clap::Parser)]
28#[command(version)]
29#[command(args_conflicts_with_subcommands = true)]
30pub struct Args {
31    #[command(subcommand)]
32    pub subcommand: Option<Subcommands>,
33    #[command(flatten)]
34    pub decode: Option<DecodeArgs>,
35    #[command(flatten)]
36    pub globals: GlobalArgs,
37}
38
39#[derive(Debug, clap::Args)]
40#[non_exhaustive]
41pub struct GlobalArgs {
42    /// Print debug information; can be repeated.
43    #[arg(short, long, global = true, action = clap::ArgAction::Count)]
44    pub verbose: u8,
45    /// Do not print logs to console.
46    #[arg(short, long, global = true, conflicts_with = "verbose")]
47    pub quiet: bool,
48    /// Whether to use colors on output.
49    #[arg(long, global = true, value_enum, default_value_t)]
50    pub color: TermColorKind,
51}
52
53#[derive(Debug, clap::Subcommand)]
54pub enum Subcommands {
55    /// Decode JPEG XL image (assumed if no subcommand is specified).
56    #[command(short_flag = 'd')]
57    Decode(DecodeArgs),
58    /// Print information about JPEG XL image.
59    #[command(short_flag = 'I')]
60    Info(InfoArgs),
61    /// (devtools) Generate frames for progressive decoding animation.
62    #[cfg(feature = "__devtools")]
63    Progressive(ProgressiveArgs),
64    /// (devtools) Generate fixture to use for testing.
65    #[cfg(feature = "__devtools")]
66    GenerateFixture(GenerateFixtureArgs),
67    /// (devtools) Dump JPEG bitstream reconstruction data.
68    #[cfg(feature = "__devtools")]
69    DumpJbrd(DumpJbrd),
70    /// (devtools, ffmpeg) Load an image byte-by-byte.
71    #[cfg(feature = "__ffmpeg")]
72    SlowMotion(SlowMotionArgs),
73}
74
75#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, clap::ValueEnum)]
76pub enum TermColorKind {
77    /// Use colors if the output is tty.
78    #[default]
79    Auto,
80    /// Never use colors.
81    Never,
82    /// Always use colors.
83    Always,
84}