Skip to content

Commit

Permalink
Initial commit of bkt, setting up repo boilerplate and basic interface.
Browse files Browse the repository at this point in the history
  • Loading branch information
dimo414 committed Feb 2, 2021
0 parents commit 4f5586d
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/rust.yml
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 }}'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
47 changes: 47 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions Cargo.toml
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"] }
5 changes: 5 additions & 0 deletions README.md
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.
27 changes: 27 additions & 0 deletions src/main.rs
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);
}

0 comments on commit 4f5586d

Please sign in to comment.