Skip to content

Commit 2ae1d3d

Browse files
authored
Merge pull request #9811 from habitat-sh/agadgil/prune-clap-v2-support-hab-cli
pruned `clapv2` from habitat
2 parents c9e37fc + aab2a1c commit 2ae1d3d

51 files changed

Lines changed: 128 additions & 8767 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 55 additions & 292 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

components/common/Cargo.toml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@ workspace = "../../"
1010
async-trait = "*"
1111
bimap = "*"
1212
bitflags = "*"
13-
clap = { git = "https://github.com/habitat-sh/clap.git", branch = "v2-master", features = [
14-
"suggestions",
15-
"color",
16-
"unstable",
17-
] , optional = true }
1813
# TODO: When we finally get rid of everything, in clap_v2 make it just `clap`.
1914
# This is required right now because we would like to start common Validation code for all
2015
# the other packages that are using it.
@@ -69,9 +64,7 @@ nix = { version = "*", features = ["signal", "user"] }
6964
winapi = { version = "^0.3", features = ["consoleapi", "processenv"] }
7065

7166
[features]
72-
v2 = ["clap"]
73-
v4 = []
74-
default = ["v4"]
67+
default = []
7568
deadlock_detection = []
7669
lock_as_rwlock = []
7770
lock_as_mutex = []

components/common/src/cli.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
//! for use in the clap layer of the application. This is not the final form for defaults.
33
//! Eventually this will be composed of fully typed default values. But as a first step we
44
//! need a spot to consolidate those values and help simplify some of the logic around them.
5-
#[cfg(feature = "v2")]
6-
use clap::{value_t,
7-
ArgMatches};
85
use habitat_core::{self,
96
os::process::{ShutdownSignal,
107
ShutdownTimeout},
@@ -47,18 +44,6 @@ pub const DEFAULT_BINLINK_DIR: &str = "/bin";
4744
#[cfg(target_os = "macos")]
4845
pub const DEFAULT_BINLINK_DIR: &str = "/usr/local/bin";
4946

50-
#[cfg(feature = "v2")]
51-
pub fn key_cache_from_matches(matches: &ArgMatches<'_>)
52-
-> crate::error::Result<habitat_core::crypto::keys::KeyCache> {
53-
use habitat_core::crypto::keys::KeyCache;
54-
use std::path::PathBuf;
55-
56-
let path = value_t!(matches, "CACHE_KEY_PATH", PathBuf).expect("CACHE_KEY_PATH required");
57-
let key_cache = KeyCache::new(path);
58-
key_cache.setup()?;
59-
Ok(key_cache)
60-
}
61-
6247
pub fn is_toml_file(val: &str) -> bool {
6348
let extension = Path::new(&val).extension().and_then(OsStr::to_str);
6449
matches!(extension, Some("toml"))

components/common/src/cli/clap_validators.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ impl clap_v4::builder::TypedValueParser for FileExistsValueParser {
8989
}
9090
}
9191

92-
// TODO: This will be used by `hab config`. This implements the functionality of
93-
// `file_exists_or_stdin` validator in Clap v2.
92+
// This validator will be used by `hab config`
9493
/// Struct implementing validator that validates the valie is a valid 'file' or 'stdin'
9594
#[derive(Clone)]
9695
pub struct FileExistsOrStdinValueParser;

components/common/src/types.rs

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use crate::{error::Error,
22
util};
3-
#[cfg(feature = "v2")]
4-
use clap::ArgMatches;
53

64
use native_tls::Certificate;
75
use serde::{Deserialize,
@@ -141,18 +139,6 @@ impl EventStreamToken {
141139
}
142140
}
143141

144-
#[cfg(feature = "v2")]
145-
impl<'a> From<&'a ArgMatches<'a>> for EventStreamToken {
146-
/// Create an instance of `EventStreamToken` from validated
147-
/// user input.
148-
fn from(m: &ArgMatches) -> Self {
149-
m.value_of(Self::ARG_NAME)
150-
.expect("HAB_AUTOMATE_AUTH_TOKEN should be set")
151-
.parse()
152-
.expect("HAB_AUTOMATE_AUTH_TOKEN should be validated at this point")
153-
}
154-
}
155-
156142
impl FromStr for EventStreamToken {
157143
type Err = Error;
158144

@@ -252,15 +238,6 @@ impl EventStreamServerCertificate {
252238
pub fn validate(value: String) -> result::Result<(), String> {
253239
value.parse::<Self>().map(|_| ()).map_err(|e| e.to_string())
254240
}
255-
256-
#[cfg(feature = "v2")]
257-
/// Create an instance of `EventStreamServerCertificate` from validated user input.
258-
pub fn from_arg_matches(m: &ArgMatches) -> Option<Self> {
259-
m.value_of(Self::ARG_NAME).map(|value| {
260-
value.parse().expect("EVENT_STREAM_SERVER_CERTIFICATE \
261-
should be validated")
262-
})
263-
}
264241
}
265242

266243
impl FromStr for EventStreamServerCertificate {

components/hab/Cargo.toml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,7 @@ rustls-webpki = { version = "*", features = ["alloc"] }
5454
tempfile = "*"
5555

5656

57-
clap = { git = "https://github.com/habitat-sh/clap.git", branch = "v2-master", features = [ "suggestions", "color", "unstable" ] , optional = true}
58-
configopt = { git = "https://github.com/habitat-sh/configopt.git" , optional = true}
59-
structopt = { git = "https://github.com/habitat-sh/structopt.git" , optional = true}
60-
61-
clap_v4 = { version = "4", package = "clap", features = ["env", "derive", "string", "wrap_help"], optional = true }
57+
clap_v4 = { version = "4", package = "clap", features = ["env", "derive", "string", "wrap_help"]}
6258

6359
clap_complete = "*"
6460

@@ -72,9 +68,7 @@ winapi = { version = "^0.3", features = ["winuser", "windef"] }
7268
winreg = "*"
7369

7470
[features]
75-
v2 = [ "clap", "configopt", "structopt" ]
76-
v4 = [ "clap_v4" ]
77-
default = ["supported_targets", "v4"]
71+
default = ["supported_targets"]
7872
functional = []
7973
supported_targets = ["habitat_core/supported_targets"]
8074
aarch64-linux = ["habitat_core/aarch64-linux"]

0 commit comments

Comments
 (0)