cargo-whatfeatures 0.9.13

display features, versions and dependencies of crates
Documentation
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
use crate::{printer::YankStatus, Theme};
use pico_args::Arguments;
use std::path::{Path, PathBuf};

#[allow(missing_docs)]
#[derive(Debug)]
pub enum Error {
    PkgIdIsLocal,

    FlagRequiresRemote {
        provided_short: String,
        provided_long: String,
    },

    NameRequired,

    Exclusive {
        bad: Vec<Vec<String>>,
    },

    ExclusiveWith {
        bad: Vec<Vec<String>>,
        provided_short: String,
        provided_long: String,
    },
    Inclusive {
        bad: Vec<Vec<String>>,
        provided_short: String,
        provided_long: String,
    },

    NoCrateName,
    NoCrateOrPkgId,

    TooManyCrates {
        n: usize,
    },

    UnknownOption {
        option: String,
        allowed: Vec<&'static str>,
    },
}

impl Error {
    fn exclusive<I, A, S>(bad: I) -> Self
    where
        I: IntoIterator<Item = A>,
        A: IntoIterator<Item = S>,
        S: ToString,
    {
        Self::Exclusive {
            bad: bad
                .into_iter()
                .map(|s| s.into_iter().map(|s| s.to_string()).collect())
                .collect(),
        }
    }

    fn inclusive_with<I, A, S>(bad: I, short: impl ToString, long: impl ToString) -> Self
    where
        I: IntoIterator<Item = A>,
        A: IntoIterator<Item = S>,
        S: ToString,
    {
        Self::Inclusive {
            bad: bad
                .into_iter()
                .map(|s| s.into_iter().map(|s| s.to_string()).collect())
                .collect(),
            provided_short: short.to_string(),
            provided_long: long.to_string(),
        }
    }

    fn exclusive_with<I, A, S>(bad: I, short: impl ToString, long: impl ToString) -> Self
    where
        I: IntoIterator<Item = A>,
        A: IntoIterator<Item = S>,
        S: ToString,
    {
        Self::ExclusiveWith {
            bad: bad
                .into_iter()
                .map(|s| s.into_iter().map(|s| s.to_string()).collect())
                .collect(),
            provided_short: short.to_string(),
            provided_long: long.to_string(),
        }
    }
}

impl std::fmt::Display for Error {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match self {
            Self::PkgIdIsLocal => {
                write!(f, "pkgid must be a `name:semver` pair, not a local path.")?;
            }

            Self::FlagRequiresRemote {
                provided_short,
                provided_long,
            } => {
                write!(
                    f,
                    "flag [{}, {}] requires that the crate be remote",
                    provided_short, provided_long
                )?;
            }

            Self::NameRequired => {
                write!(f, "A package name must be supplied")?;
            }

            Self::Exclusive { bad } => {
                let flags = join_iter(
                    bad.iter().map(|s| s.as_slice()),
                    |n| format!("`{}`", n),
                    |n| format!("`[{}]`", n.join(", ")),
                    " and ",
                );
                write!(f, "the flags {} cannot be used at the same time", flags)?;
            }

            Self::ExclusiveWith {
                bad,
                provided_short,
                provided_long,
            } => {
                let flags = join_iter(
                    bad.iter().map(|s| s.as_slice()),
                    |n| format!("`{}`", n),
                    |n| format!("`[{}]`", n.join(", ")),
                    " or ",
                );
                write!(
                    f,
                    "`[{}, {}]` cannot be used with: {}",
                    provided_short, provided_long, flags
                )?;
            }

            Self::Inclusive {
                bad,
                provided_short,
                provided_long,
            } => {
                let flags = join_iter(
                    bad.iter().map(|s| s.as_slice()),
                    |n| format!("`{}`", n),
                    |n| format!("`[{}]`", n.join(", ")),
                    " or ",
                );
                write!(
                    f,
                    "`[{}, {}]` must be used with one of {}",
                    provided_short, provided_long, flags
                )?;
            }

            Self::NoCrateName => {
                write!(f, "a crate name must be provided")?;
            }

            Self::NoCrateOrPkgId => {
                write!(f, "no crate name, or pkgid spec provided.")?;
            }

            Self::TooManyCrates { n } => {
                write!(
                    f,
                    "too many crate names ({}) were provided. only 1 is allowed",
                    n
                )?;
            }

            Self::UnknownOption { option, allowed } => {
                let options =
                    allowed
                        .iter()
                        .map(|s| format!("'{}'", s))
                        .fold(String::new(), |mut a, c| {
                            if !a.is_empty() {
                                a.push_str(", ");
                            }
                            a.push_str(&c);
                            a
                        });

                write!(
                    f,
                    "unknown option '{}'. only one of [{}] is allowed.",
                    option, options
                )?;
            }
        };

        Ok(())
    }
}

impl std::error::Error for Error {}

fn join_iter<'a, I, S, O, M, W>(iter: I, one: O, many: M, with: W) -> String
where
    S: AsRef<str> + 'a,
    I: Iterator<Item = &'a [S]> + 'a,

    O: Fn(&S) -> String,
    M: Fn(&'a [S]) -> String,
    W: std::fmt::Display,
{
    let sep = with.to_string();
    iter.map(|s| match s {
        [n] => one(n),
        n => many(n),
    })
    .fold(String::new(), |mut a, c| {
        if !a.is_empty() {
            a.push_str(&sep);
        }
        a.push_str(&c);
        a
    })
}

#[derive(PartialEq)]
enum Color {
    Always,
    Auto,
    Never,
}

impl std::str::FromStr for Color {
    type Err = Error;
    fn from_str(input: &str) -> Result<Self, Self::Err> {
        match &input.to_lowercase()[..] {
            "always" => Ok(Self::Always),
            "auto" => Ok(Self::Auto),
            "never" => Ok(Self::Never),
            option => Err(Error::UnknownOption {
                option: option.to_string(),
                allowed: vec!["always", "auto", "never"],
            }),
        }
    }
}

// TODO verify that 'local' contains a Cargo.toml
// TODO verify that 'semver' is a correct semver
/// A 'pkgid' spec, either local or 'remote'
#[derive(Debug)]
pub enum PkgId {
    /// Remote path (e.g. look it up in the registry)
    Remote {
        /// Name of the crate
        name: String,
        /// Specified semver
        semver: Option<String>,
    }, // TODO supports more registries than just crates.io
    /// Local directory or file
    Local(PathBuf),
}

impl PkgId {
    /// Name of the package
    pub fn name(&self) -> &str {
        match &self {
            Self::Remote { name, .. } => name.as_str(),
            Self::Local(s) => s.to_str().unwrap(),
        }
    }

    /// Whether this is a local package
    pub fn is_local(&self) -> bool {
        matches!(self, Self::Local { .. })
    }
}

impl std::fmt::Display for PkgId {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        match &self {
            Self::Remote { name, semver } => {
                write!(f, "{}", name)?;
                if let Some(ver) = &semver {
                    write!(f, ":{}", ver)?;
                }
                Ok(())
            }
            Self::Local(l) => write!(f, "{}", l.display()),
        }
    }
}

impl std::str::FromStr for PkgId {
    type Err = Error;
    fn from_str(input: &str) -> Result<Self, Self::Err> {
        let path = Path::new(input);
        if path.is_dir() || path.is_file() {
            return Err(Error::PkgIdIsLocal);
        }

        let mut iter = input.splitn(2, ':');
        let name = iter.next().ok_or_else(|| Error::NameRequired)?;
        let semver = iter.next().map(ToString::to_string);

        let path = Path::new(name);
        if path.is_dir() || path.is_file() {
            return Err(Error::PkgIdIsLocal);
        }

        Ok(Self::Remote {
            name: name.to_string(),
            semver,
        })
    }
}

/// Input for the program
#[derive(Debug)]
pub struct Args {
    /// Verbose output (list leaves, etc.)
    pub verbose: bool,

    /// Should we show private crates?
    pub show_private: bool,

    /// Should we list all versions?
    pub list: bool,

    /// Should no features be printed out?
    pub no_features: bool,

    /// Should we should the dependencies?
    pub show_deps: bool,

    /// Should we show yanked versions?
    pub show_yanked: Option<YankStatus>,

    /// Should we show only the name and version?
    pub name_only: bool,

    /// The pkgid specified
    pub pkgid: PkgId,

    /// Don't try to connect to the internet
    pub offline: bool,

    /// The theme to use
    pub theme: Theme,

    /// Don't treat this crate as a member of a workspace
    pub local_only: bool,

    /// Output json instead of human readable
    pub json: bool,
}

impl Args {
    fn try_parse_help(args: &mut Arguments) -> anyhow::Result<()> {
        if args.contains(["-V", "--version"]) {
            print_version()
        }

        if args
            .subcommand()?
            .as_deref()
            .filter(|&s| format!("cargo-{}", s) == env!("CARGO_PKG_NAME"))
            .is_none()
        {
            print_help(Help::Cargo)
        }

        match (args.contains("-h"), args.contains("--help")) {
            (true, ..) => print_help(Help::Short),
            (.., true) => print_help(Help::Long),
            _ => {}
        }

        Ok(())
    }

    fn try_parse_cache(args: &mut Arguments) -> anyhow::Result<()> {
        if args.contains("--print-cache-dir") {
            println!("{}", crate::util::cache_dir()?.display());
            std::process::exit(0);
        }

        if args.contains("--purge") {
            let total = crate::Registry::from_local()?.purge_local_cache()?;
            println!(
                "purged {} crates from {}",
                total,
                crate::util::cache_dir()?.display()
            );
            std::process::exit(0)
        }

        Ok(())
    }

    fn try_parse_yank_status(args: &mut Arguments) -> anyhow::Result<Option<YankStatus>> {
        args.opt_value_from_fn(["-y", "--show-yanked"], |s| match s {
            "exclude" => Ok(YankStatus::Exclude),
            "include" => Ok(YankStatus::Include),
            "only" => Ok(YankStatus::Only),
            s => Err(Error::UnknownOption {
                option: s.to_string(),
                allowed: vec!["exclude", "include", "only"],
            }),
        })
        .map_err(Into::into)
    }

    fn try_parse_color(args: &mut Arguments) -> anyhow::Result<()> {
        let color: Option<Color> = args.opt_value_from_str(["-c", "--color"])?;

        let disable_colors = std::env::var("NO_COLOR").is_ok();
        if disable_colors
            || color == Some(Color::Never)
            || cfg!(windows) && !yansi::Paint::enable_windows_ascii()
        {
            yansi::Paint::disable()
        }

        Ok(())
    }

    fn try_parse_theme(args: &mut Arguments) -> anyhow::Result<Theme> {
        let theme_name: Option<String> = args.opt_value_from_str("--theme")?;
        match theme_name.as_deref().map(Self::try_parse_theme_name) {
            Some(Ok(theme)) => Ok(theme),
            Some(err) => err,
            None => Ok(Theme::default()),
        }
    }

    fn try_parse_theme_name(theme_name: &str) -> anyhow::Result<Theme> {
        Ok(match &*theme_name.to_lowercase() {
            "colorful" => Theme::colorful(),
            "basic" => Theme::basic(),
            "palette" => Theme::palette(),
            "none" => Theme::none(),
            _ => anyhow::bail!("invalid theme name, available: [colorful, basic, palette, none]"),
        })
    }

    fn verify_flags(this: Self) -> anyhow::Result<Self> {
        let Self {
            list,
            no_features,
            show_private,
            show_deps,
            name_only,
            pkgid,
            show_yanked,
            ..
        } = &this;

        /*
        list is exclusive with:
            no_features
            show_deps
            crate_name

        name_only is exclusive with:
            show_deps

        no_features is inclusive with:
            no_features
            show_deps
        */

        if *list {
            let mut bad = vec![];
            if *no_features {
                bad.push(vec!["-n", "--no-features"]);
            }
            if *show_deps {
                bad.push(vec!["-d", "--deps"]);
            }
            if *show_private {
                bad.push(vec!["-r", "--restricted"]);
            }
            if pkgid.is_local() {
                bad.push(vec!["<crate>"]);
            }
            if !bad.is_empty() {
                anyhow::bail!(Error::exclusive_with(bad, "-l", "--list"))
            }
        }

        if show_yanked.is_some() && pkgid.is_local() {
            anyhow::bail!(Error::FlagRequiresRemote {
                provided_short: "-y".into(),
                provided_long: "--show-yanked".into(),
            });
        }

        if *name_only {
            let mut bad = vec![];
            if *show_deps {
                bad.push(vec!["-d", "--deps"]);
            }

            if !bad.is_empty() {
                anyhow::bail!(Error::exclusive_with(bad, "-s", "--short"))
            }
        }

        if *no_features && (!show_deps && !*name_only) {
            anyhow::bail!(Error::inclusive_with(
                vec![vec!["-d", "--deps"], vec!["-s", "--short"]],
                "-n",
                "--no-features"
            ))
        }

        if !pkgid.is_local() && *show_private {
            anyhow::bail!(Error::inclusive_with(
                vec![vec!["--manifest-path", "or implicit <crate>"]],
                "-r",
                "--restricted"
            ))
        }

        Ok(this)
    }

    /// Parse the arguments
    pub fn parse() -> anyhow::Result<Self> {
        let mut args = pico_args::Arguments::from_env();

        Self::try_parse_help(&mut args)?;
        Self::try_parse_cache(&mut args)?;
        Self::try_parse_color(&mut args)?;

        let show_yanked = Self::try_parse_yank_status(&mut args)?;

        let list = args.contains(["-l", "--list"]);
        let show_private = args.contains(["-r", "--restricted"]);
        let name_only = args.contains(["-s", "--short"]);
        let no_features = args.contains(["-n", "--no-features"]);
        let show_deps = args.contains(["-d", "--deps"]);
        let offline = args.contains(["-o", "--offline"]);
        let verbose = args.contains(["-v", "--verbose"]);
        let local_only = args.contains(["-t", "--this-crate"]);
        let json = args.contains(["-j", "--json"]);

        let mut theme = Self::try_parse_theme(&mut args)?;

        if let Some(override_theme) = std::env::var("WHATFEATURES_THEME")
            .ok()
            .as_deref()
            .map(Args::try_parse_theme_name)
        {
            theme = override_theme?
        }

        let manifest_path: Option<PathBuf> = args.opt_value_from_str("--manifest-path")?;
        let mut pkgid: Option<PkgId> = args.opt_value_from_str(["-p", "--pkgid"])?;

        if pkgid.is_some() && manifest_path.is_some() {
            // "both `[-p, --pkgid]` and `--manifest-path` cannot be used at the same time"
            // TODO this could be done with like 3 less allocations
            anyhow::bail!(Error::exclusive(vec![
                vec!["-p", "--pkgid"],
                vec!["--manifest-path"],
            ]));
        }

        // TODO redo all of this
        let mut crate_names = args
            .finish()
            .into_iter()
            .map(|s| s.to_string_lossy().to_string())
            .collect::<Vec<_>>();

        match crate_names.len() {
            0 if pkgid.is_some() => {}
            0 if manifest_path.is_some() => {
                pkgid.replace(PkgId::Local(manifest_path.unwrap()));
            }
            0 => anyhow::bail!(Error::NoCrateName),
            n if n > 0 && pkgid.is_some() => anyhow::bail!(Error::exclusive(vec![
                vec!["-p", "--pkgid"],
                vec!["<crate>"]
            ])),
            1 => {
                // TODO make this determine if its a remote or local package (prefer remote)
                let name = crate_names.remove(0);
                let p = match name.parse() {
                    Ok(pkgid) => pkgid,
                    Err(..) => PkgId::Local(PathBuf::from(name)),
                };
                pkgid.replace(p);
            }
            n => anyhow::bail!(Error::TooManyCrates { n }),
        };

        if pkgid.is_none() {
            anyhow::bail!(Error::NoCrateOrPkgId)
        }

        Self::verify_flags(Self {
            verbose,

            list,
            show_private,

            no_features,
            show_deps,
            show_yanked,
            name_only,

            pkgid: pkgid.unwrap(),
            local_only,

            offline,

            theme,

            json,
        })
    }
}

pub enum Help {
    Long,
    Short,
    Cargo,
}

fn print_help(help: Help) -> ! {
    static CARGO_HELP: &str = "USAGE:
    cargo <SUBCOMMAND>

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    help             Prints this message or the help of the given subcommand(s)
    whatfeatures     the `whatfeatures` command";

    static SHORT_HELP: &str = r#"the `whatfeatures` command

USAGE:
    cargo whatfeatures [FLAGS] [OPTIONS] <crate>

FLAGS:
    -h, --help                  Prints help information
    -V, --version               Displays the program name and version
    -d, --deps                  Display dependencies for the crate
    -n, --no-features           Disable listing the features for the crate
    -r, --restricted            When used on a local workspace, also included private packages
    -t, --this-crate            When used on a crate in a local workspace, don't traverse to the root
    -l, --list                  List all versions for the crate
    -s, --short                 Display only the name and latest version
    -v, --verbose               Print all leaf nodes and optional deps
    -o, --offline               Don't connect to the internet, limits the availities of this.
    -j, --json                  Prints json rather than a human-readable format
    --print-cache-dir           Prints out the path to the cache directory
    --purge                     Purges the local cache
    --theme                     Use a different theme

OPTIONS:
    -c, --color <WHEN>          Attempts to use colors when printing as text [default: auto]
    -p, --pkgid <SPEC>          A `pkgid` spec. e.g. cargo:1.43.0
    --manifest-path <PATH>      A path to the Cargo.toml you want to read, locally.
    -y, --show-yanked <yanked>  Shows any yanked versions when using `--list`. [default: exclude].

ARGS:
    <crate>                     The name of a remote crate to retrieve information for.
                                Or local path to a directory containing Cargo.toml, or Cargo.toml itself.
                                This is exclusive with -p, --pkgid and with --manifest-path.

CONFIG:
    WHATFEATURES_THEME          [colorful, basic, palette, none]
"#;

    static LONG_HELP: &str = r#"the `whatfeatures` command

    USAGE:
        cargo whatfeatures [FLAGS] [OPTIONS] <crate>

    FLAGS:
        -h, --help
            Prints help information

        -V, --version
            Displays the program name and version

        -d, --deps
            Display dependencies for the crate
            This will list the required dependencies

        -n, --no-features
            Disable listing the features for the crate

        -r, --restricted
            When used on a local workspace, also included private packages

        -t, --this-crate
            When used on a crate in a local workspace, don't traverse to the root
            Normally, if you're in a workspace member, it will traverse to the root
            and list all sibling crates as well. This flag disabled that behavior

        -l, --list
            List all versions for the crate.
            When using the `-y` option, yanked crates can be filtered.

        -s, --short
            Display only the name and latest version, such as foo = 0.1.2

        -v, --verbose
            When this is enabled, all 'implied' features will be listed.
            Also, optional dependencies will be listed. Optional deps are technically features.

        -o, --offline
            Don't connect to the internet, limits the availities of this.
            If the crate is in either cargo's local registry, or whatfeatures' cache
            then this will work normally, otherwise it'll give you a nice error.

        -j, --json
            This outputs JSON rather than the human readable format

        --print-cache-dir
            Prints out the path to the cache directory

        --purge
            Purges the local cache. The command will automatically clean up after
            itself if it sees the crate in the cargo local registry. If its not
            in the cargo registry, it'll download the crate from crates.io and place
            it in its cache. This flag causes that cache to become invalidated.

            The cache is located at these locations:
            * Linux: $XDG_CACHE_HOME/museun/whatfeatures
            * Windows: %LOCALAPPDATA/museun/whatfeatures
            * macOS: $HOME/Library/Caches/museun/whatfeatures

        --theme [colorful, basic, palette, none]
            use this provided theme

    OPTIONS:
        -c, --color [always, auto, never]
            Attempts to use colors when printing as text [default: auto]
            *NOTE* When NO_COLOR is set to any value, all colors will be disabled

        -p, --pkgid <semver>
            A specific version to lookup. e.g. foo:0.7.1
            If this is not provided, then the latest crate is used.

        --manifest-path <PATH>
            A path to the Cargo.toml you want to read, locally.
            This can be the root directory to the crate/workspace, or an explicit path to a Cargo.toml
            Use this to read from a local crate, rather than a remote one.

        -y, --show-yanked <exclude, include, only>
            Shows any yanked versions when using `--list`. [default: exclude].
            When 'exclude' is provided, only active releases versions will be listed
            When 'include' is provided, the listing will include yanked versions along with active releases.
            When 'only' is provided, only yanked versions will be listed

    ARGS:
        <crate>  The name of the crate to retrieve information for.

                 If this is a path to a directory containing a Cargo.toml,
                 or the path to the Cargo.toml then it'll use that directory
                 as the crate to operate one

                 This is exclusive with -p, --pkgid and with --manifest-path.

    CONFIG:
        WHATFEATURES_THEME  [colorful, basic, palette, none]
                            This allows you to override the --theme flag with an environmental variable
"#;

    println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));

    match help {
        Help::Long => println!("{}", LONG_HELP),
        Help::Short => println!("{}", SHORT_HELP),
        Help::Cargo => println!("{}", CARGO_HELP),
    }

    std::process::exit(0)
}

fn print_version() -> ! {
    println!("{} {}", env!("CARGO_PKG_NAME"), env!("CARGO_PKG_VERSION"));
    std::process::exit(0)
}