Skip to main content

neo_decompiler/decompiler/
output_format.rs

1#[cfg(feature = "cli")]
2use clap::ValueEnum;
3
4/// Select which decompiler outputs should be generated.
5#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
6#[cfg_attr(feature = "cli", derive(ValueEnum))]
7pub enum OutputFormat {
8    /// Emit pseudocode output.
9    Pseudocode,
10    /// Emit a higher-level structured output.
11    HighLevel,
12    /// Emit C# source code output.
13    // Override clap's default kebab-case derivation (`c-sharp`) so the
14    // CLI accepts the same `csharp` token as `--format csharp`. The
15    // legacy `c-sharp` form is kept as an alias for back-compat with
16    // any scripts that pinned the old spelling.
17    #[cfg_attr(feature = "cli", value(name = "csharp", alias = "c-sharp"))]
18    CSharp,
19    /// Emit all supported outputs.
20    #[default]
21    All,
22}
23
24impl OutputFormat {
25    pub(super) fn wants_pseudocode(self) -> bool {
26        matches!(self, OutputFormat::Pseudocode | OutputFormat::All)
27    }
28
29    pub(super) fn wants_high_level(self) -> bool {
30        matches!(self, OutputFormat::HighLevel | OutputFormat::All)
31    }
32
33    pub(super) fn wants_csharp(self) -> bool {
34        matches!(self, OutputFormat::CSharp | OutputFormat::All)
35    }
36}