with_java/
models.rs

1use std::collections::HashMap;
2
3use clap::{Parser, Subcommand};
4
5#[derive(Debug, Parser)]
6#[command(author, version, about, long_about = None)]
7pub struct Cli {
8    #[command(subcommand)]
9    commands: Commands,
10}
11
12impl Cli {
13    pub fn commands(&self) -> &Commands {
14        &self.commands
15    }
16}
17
18///
19/// Environment wrapper for Java versions
20///
21#[derive(Debug, Subcommand)]
22pub enum Commands {
23    /// add a new named entry to the given Java sdk path
24    Add { name: String, path: String },
25
26    /// remove entry with the given name
27    Remove { name: String },
28
29    /// list all available entries
30    List,
31
32    /// call a command with `$JAVA_HOME` and binary path set to
33    /// the corresponding entry
34    #[command(allow_hyphen_values = true)]
35    Do { name: String, command: Vec<String> },
36}
37
38pub type Entries = HashMap<String, String>;