-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial commit of bkt, setting up repo boilerplate and basic interface.
- Loading branch information
0 parents
commit 4f5586d
Showing
6 changed files
with
150 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Rust | ||
|
||
on: [push] | ||
|
||
# See https://github.com/sharkdp/bat/blob/master/.github/workflows/CICD.yml for a more intricate CI/CD | ||
jobs: | ||
CI: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- uses: actions-rs/clippy-check@v1 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
args: --all-targets --all-features | ||
- name: Check | ||
run: cargo check --all-targets --verbose | ||
- name: Run tests | ||
run: cargo test --verbose | ||
|
||
CD: | ||
runs-on: ubuntu-latest | ||
needs: CI | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
arch: | ||
- { target: arm-unknown-linux-gnueabihf , use-cross: true } | ||
- { target: i686-unknown-linux-gnu , use-cross: true } | ||
- { target: x86_64-unknown-linux-gnu } | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Extract crate information | ||
shell: bash | ||
run: | | ||
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' Cargo.toml)" >> "$GITHUB_ENV" | ||
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n1)" >> "$GITHUB_ENV" | ||
- name: Build | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: ${{ matrix.arch.use-cross }} | ||
command: build | ||
args: --release --target=${{ matrix.arch.target }} | ||
|
||
- name: Upload package artifact | ||
uses: actions/upload-artifact@master | ||
with: | ||
name: '${{ env.PROJECT_NAME }}.v${{ env.PROJECT_VERSION }}.${{ matrix.arch.target }}' | ||
path: 'target/${{ matrix.arch.target }}/release/${{ env.PROJECT_NAME }}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
[package] | ||
name = "bkt" | ||
version = "0.1.0" | ||
authors = ["Michael Diamond <[email protected]>"] | ||
description = "CLI to cache subprocess invocations" | ||
repository = "http://github.com/dimo414/bkt" | ||
homepage = "http://bkt.rs/" | ||
license = "MIT" | ||
keywords = ["cache", "caching", "subprocess", "cli", "shell"] | ||
categories = ["caching", "command-line-utilities"] | ||
edition = "2018" | ||
include = [ | ||
"**/*.rs", | ||
"Cargo.*", | ||
"README.md", | ||
"LICENSE", | ||
] | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
clap = { version = "2.33.3", default_features = false, features = ["vec_map"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# `bkt` | ||
|
||
`bkt` is a subprocess caching utility written in Rust, inspired by [bash-cache](https://github.com/dimo414/bash-cache). | ||
|
||
It is still under development. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#[macro_use] extern crate clap; | ||
|
||
use std::io::{self, Write}; | ||
use clap::{Arg, App}; | ||
use std::process::{Command, exit}; | ||
|
||
fn main() { | ||
let matches = App::new(crate_name!()) | ||
.version(crate_version!()) | ||
.about(crate_description!()) | ||
.arg(Arg::with_name("command") | ||
.required(true) | ||
.multiple(true) | ||
.last(true) | ||
.help("The command to run")) | ||
.get_matches(); | ||
|
||
let command: Vec<_> = matches.values_of("command").expect("Required").collect(); | ||
|
||
if let Ok(result) = Command::new(&command[0]).args(&command[1..]).output() { | ||
io::stdout().write_all(&result.stdout).unwrap(); | ||
io::stderr().write_all(&result.stderr).unwrap(); | ||
exit(result.status.code().unwrap()); | ||
} | ||
|
||
exit(127); | ||
} |