Skip to content

Commit

Permalink
Addition of 'syv' program
Browse files Browse the repository at this point in the history
However, building all of them isn't that easy it seems.
  • Loading branch information
Byron committed Apr 2, 2018
1 parent 2a78554 commit b9e91aa
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 15 deletions.
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ travis-ci = { repository = "share-secrets-safely/cli" }

[features]
default = []
vault = ["sheesy-vault", "conv", "gpgme"]
vault = ["sheesy-vault", "conv", "gpgme", "lazy_static"]
rest = ["sheesy-tools", "glob", "conv", "itertools", "lazy_static", "atty"]

[[bin]]
Expand All @@ -27,12 +27,12 @@ required-features = ["vault", "rest"]
doctest = false
doc = false

# [[bin]]
# name = "syv"
# path = "src/syv.rs"
# required-features = ["vault"]
# doctest = false
# doc = false
[[bin]]
name = "syv"
path = "src/syv.rs"
required-features = ["vault"]
doctest = false
doc = false

[dependencies]
clap = "~2.31"
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ asciinema-upload: build-docs-image $(MUSL_EXE) $(CAST)
asciinema upload $(CAST)

$(EXE): always
cargo build
cargo build --bin=sy --all-features

$(RELEASE_EXE): always
cargo build --release
cargo build --release --bin=sy --all-features

$(MUSL_EXE): build-linux-musl

Expand Down Expand Up @@ -116,10 +116,10 @@ build-musl-image:
docker build -t $(MY_MUSL_IMAGE) - < etc/docker/Dockerfile.musl-build

build-linux-musl: build-musl-image
$(MUSL_DOCKER_ARGS) cargo build --target=x86_64-unknown-linux-musl
$(MUSL_DOCKER_ARGS) cargo build --bin=sy --all-features --target=x86_64-unknown-linux-musl

release-linux-musl: build-musl-image
docker run -v $$PWD/.docker-cargo-cache:/root/.cargo -v "$$PWD:/volume" --rm $(MY_MUSL_IMAGE) cargo build --target=x86_64-unknown-linux-musl --release
docker run -v $$PWD/.docker-cargo-cache:/root/.cargo -v "$$PWD:/volume" --rm $(MY_MUSL_IMAGE) cargo build --bin=sy --all-features --target=x86_64-unknown-linux-musl --release

interactive-linux-musl: build-musl-image
$(DOCKER_ARGS) -it $(MY_MUSL_IMAGE)
Expand Down
10 changes: 8 additions & 2 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use clap::App;
use clap::AppSettings;

#[cfg(feature = "rest")]
mod completions;
Expand All @@ -20,16 +19,23 @@ where
pub app: App<'a, 'b>,
}

#[cfg(all(feature = "rest", feature = "vault"))]
#[cfg(feature = "vault")]
impl<'a, 'b> CLI<'a, 'b>
where
'a: 'b,
{
pub fn name() -> &'static str {
"sy"
}
}

#[cfg(all(feature = "rest", feature = "vault"))]
impl<'a, 'b> CLI<'a, 'b>
where
'a: 'b,
{
pub fn new() -> Self {
use clap::AppSettings;
let app: App = app_from_crate!()
.setting(AppSettings::VersionlessSubcommands)
.setting(AppSettings::DeriveDisplayOrder)
Expand Down
1 change: 1 addition & 0 deletions src/cli/util.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[cfg(feature = "rest")]
pub fn output_formats() -> &'static [&'static str] {
&["json", "yaml"]
}
1 change: 1 addition & 0 deletions src/parse/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use failure::Error;
use std::ffi::OsStr;
use std::str::FromStr;

#[cfg(feature = "rest")]
pub fn optional_args_with_value<F, T>(args: &ArgMatches, name: &'static str, into: F) -> Vec<(T, usize)>
where
F: Fn(&str) -> T,
Expand Down
2 changes: 1 addition & 1 deletion src/sy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
extern crate clap;
#[macro_use]
extern crate failure;
#[cfg(feature = "rest")]
#[cfg(feature = "vault")]
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "rest")]
Expand Down
12 changes: 11 additions & 1 deletion src/syv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ extern crate clap;
#[macro_use]
extern crate failure;
#[cfg(feature = "vault")]
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "vault")]
extern crate conv;
#[cfg(feature = "vault")]
extern crate gpgme;
#[cfg(feature = "vault")]
extern crate sheesy_vault as vault;

use clap::ArgMatches;
Expand All @@ -15,7 +22,10 @@ mod parse;
use util::ok_or_exit;

fn main() {
let cli = cli::vault::new();
let cli = cli::vault::new()
.version(crate_version!())
.author(crate_authors!())
.name(crate_name!());
let matches: ArgMatches = cli.get_matches();
ok_or_exit(parse::vault::execute(&matches))
}

0 comments on commit b9e91aa

Please sign in to comment.