Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
a79d0ee6d4
|
|||
32ad2b3fd7
|
|||
0a3a4d4f74
|
|||
95f3254f81
|
|||
5894bd5bb1
|
|||
560f8f4fd0
|
|||
e1d8e27c23
|
|||
2e19df72b0
|
|||
08b3e1cf5b
|
|||
d592b5f2d8
|
|||
3f06afce02
|
|||
d553bf06b7
|
|||
7427f8f8d8
|
|||
e350d8c13d
|
|||
27f5287c82
|
|||
cf7ce40afd
|
|||
8149da56fb
|
|||
af591b9802
|
|||
300d16d630
|
|||
09f6ad35f9
|
|||
64f853d025
|
|||
07a2143d50
|
|||
0ca6347f1f
|
|||
9fc27f2c0e
|
|||
98cb397ea9
|
81
.github/workflows/release-published.yml
vendored
Normal file
81
.github/workflows/release-published.yml
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
name: release-published
|
||||
on:
|
||||
release:
|
||||
types: [published]
|
||||
|
||||
jobs:
|
||||
brew-releaser:
|
||||
name: Homebrew releaser
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Release to homebrew tap
|
||||
uses: Justintime50/homebrew-releaser@v1
|
||||
with:
|
||||
# The name of the homebrew tap to publish your formula to as it appears on GitHub.
|
||||
# Required - strings.
|
||||
homebrew_owner: kjuulh
|
||||
homebrew_tap: brew
|
||||
|
||||
# The name of the folder in your homebrew tap where formula will be committed to.
|
||||
# Default is shown - string.
|
||||
formula_folder: formula
|
||||
|
||||
# The GitHub Token (saved as a repo secret) that has `repo` permissions for the homebrew tap you want to release to.
|
||||
# Required - string.
|
||||
github_token: ${{ secrets.BREW_GITHUB_TOKEN }}
|
||||
|
||||
# Git author info used to commit to the homebrew tap.
|
||||
# Defaults are shown - strings.
|
||||
commit_owner: kjuulh
|
||||
commit_email: homebrew-releaser@kjuulh.io
|
||||
|
||||
# Custom dependencies in case other formulas are needed to build the current one.
|
||||
# Optional - multiline string.
|
||||
#depends_on: |
|
||||
|
||||
# Custom install command for your formula.
|
||||
# Required - string.
|
||||
install: 'bin.install "toolkit"'
|
||||
|
||||
# Custom test command for your formula so you can run `brew test`.
|
||||
# Optional - string.
|
||||
#test: 'assert_match("my script output", shell_output("my-script-command"))'
|
||||
|
||||
# Adds URL and checksum targets for different OS and architecture pairs. Using this option assumes
|
||||
# a tar archive exists on your GitHub repo with the following URL pattern (this cannot be customized):
|
||||
# https://github.com/{GITHUB_OWNER}/{REPO_NAME}/releases/download/{TAG}/{REPO_NAME}-{VERSION}-{OPERATING_SYSTEM}-{ARCHITECTURE}.tar.gz'
|
||||
# Darwin AMD pre-existing path example: https://github.com/justintime50/myrepo/releases/download/v1.2.0/myrepo-1.2.0-darwin-amd64.tar.gz
|
||||
# Linux ARM pre-existing path example: https://github.com/justintime50/myrepo/releases/download/v1.2.0/myrepo-1.2.0-linux-arm64.tar.gz
|
||||
# Optional - booleans.
|
||||
target_darwin_amd64: true
|
||||
target_darwin_arm64: true
|
||||
target_linux_amd64: true
|
||||
target_linux_arm64: true
|
||||
|
||||
# Update your homebrew tap's README with a table of all projects in the tap.
|
||||
# This is done by pulling the information from all your formula.rb files - eg:
|
||||
#
|
||||
# | Project | Description | Install |
|
||||
# | ------------------------------------------ | ------------ | ------------------------ |
|
||||
# | [formula_1](https://github.com/user/repo1) | helpful text | `brew install formula_1` |
|
||||
# | [formula_2](https://github.com/user/repo2) | helpful text | `brew install formula_2` |
|
||||
# | [formula_3](https://github.com/user/repo3) | helpful text | `brew install formula_3` |
|
||||
#
|
||||
# Simply place the following in your README or wrap your project in these comment tags:
|
||||
# <!-- project_table_start -->
|
||||
# TABLE HERE
|
||||
# <!--project_table_end -->
|
||||
#
|
||||
# Finally, mark `update_readme_table` as `true` in your GitHub Action config and we'll do the work of building a custom table for you.
|
||||
# Default is `false` - boolean.
|
||||
update_readme_table: true
|
||||
|
||||
# Skips committing the generated formula to a homebrew tap (useful for local testing).
|
||||
# Default is shown - boolean.
|
||||
skip_commit: false
|
||||
|
||||
# Logs debugging info to console.
|
||||
# Default is shown - boolean.
|
||||
debug: true
|
114
.github/workflows/release.yml
vendored
Normal file
114
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,114 @@
|
||||
name: release
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- next
|
||||
pull_request:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
CARGO_INCREMENTAL: 0
|
||||
|
||||
jobs:
|
||||
release:
|
||||
name: ${{ matrix.target }}
|
||||
permissions:
|
||||
contents: write
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-latest
|
||||
target: x86_64-unknown-linux-musl
|
||||
release-target: linux-amd64
|
||||
deb: true
|
||||
- os: ubuntu-latest
|
||||
target: arm-unknown-linux-musleabihf
|
||||
release-target: linux-arm
|
||||
- os: ubuntu-latest
|
||||
target: armv7-unknown-linux-musleabihf
|
||||
release-target: linux-arm7
|
||||
- os: ubuntu-latest
|
||||
target: aarch64-unknown-linux-musl
|
||||
release-target: linux-arm64
|
||||
deb: true
|
||||
|
||||
- os: macos-11
|
||||
target: x86_64-apple-darwin
|
||||
release-target: darwin-amd64
|
||||
- os: macos-11
|
||||
target: aarch64-apple-darwin
|
||||
release-target: darwin-arm64
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get version
|
||||
id: get_version
|
||||
run: sed -En 's/^version = "(.*)"/value=\1/p' Cargo.toml >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: stable
|
||||
profile: minimal
|
||||
override: true
|
||||
target: ${{ matrix.target }}
|
||||
|
||||
- name: Setup cache
|
||||
uses: Swatinem/rust-cache@v1
|
||||
with:
|
||||
key: ${{ matrix.target }}
|
||||
|
||||
- name: Build binary
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: build
|
||||
args: --release --locked --target=${{ matrix.target }} --color=always --verbose
|
||||
use-cross: ${{ runner.os == 'Linux' }}
|
||||
|
||||
- name: Install cargo-deb
|
||||
if: ${{ matrix.deb == true }}
|
||||
uses: actions-rs/install@v0.1
|
||||
with:
|
||||
crate: cargo-deb
|
||||
|
||||
- name: Build deb
|
||||
if: ${{ matrix.deb == true }}
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: deb
|
||||
args: --no-build --no-strip --output=. --target=${{ matrix.target }}
|
||||
|
||||
- name: Package (*nix)
|
||||
if: runner.os != 'Windows'
|
||||
run: >
|
||||
tar -cv
|
||||
LICENSE README.md
|
||||
man/
|
||||
-C target/${{ matrix.target }}/release/ toolkit
|
||||
| gzip --best
|
||||
> 'toolkit-${{ steps.get_version.outputs.value }}-${{ matrix.release-target }}.tar.gz'
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.release-target }}
|
||||
path: |
|
||||
*.deb
|
||||
*.tar.gz
|
||||
*.zip
|
||||
- name: Create release
|
||||
if: ${{ github.ref == 'refs/heads/main' && startsWith(github.event.head_commit.message, 'chore(release)') }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
draft: true
|
||||
files: |
|
||||
*.deb
|
||||
*.tar.gz
|
||||
*.zip
|
||||
name: ${{ steps.get_version.outputs.value }}
|
||||
tag_name: v${{ steps.get_version.outputs.value }}
|
26
Cargo.lock
generated
26
Cargo.lock
generated
@@ -178,18 +178,18 @@ checksum = "9b7820b9daea5457c9f21c69448905d723fbd21136ccf521748f23fd49e723ee"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
version = "1.0.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
@@ -265,9 +265,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.105"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -285,18 +285,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
|
||||
checksum = "6a9cd18aa97d5c45c6603caea1da6628790b37f7a34b6ca89522331c5180fed0"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.37"
|
||||
version = "1.0.38"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
|
||||
checksum = "1fb327af4685e4d03fa8cbcf1716380da910eeb2bb8be417e7f9fd3fb164f36f"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -316,7 +316,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "toolkit"
|
||||
version = "0.1.0"
|
||||
version = "0.1.2"
|
||||
dependencies = [
|
||||
"clap",
|
||||
"eyre",
|
||||
@@ -329,9 +329,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "util"
|
||||
|
@@ -1,7 +1,11 @@
|
||||
[package]
|
||||
name = "toolkit"
|
||||
version = "0.1.0"
|
||||
description = "Toolkit is an opinionated toolkit complementing a personal development workflow. Many of the commands are quite verbose, and well suited for adding to your shell toolbelt"
|
||||
version = "0.1.2"
|
||||
edition = "2021"
|
||||
license-file = "LICENSE"
|
||||
authors = ["Kasper J. Hermansen contact@kjuulh.io"]
|
||||
readme = "README.md"
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
|
@@ -1,5 +1,6 @@
|
||||
use std::io::Write;
|
||||
|
||||
use clap::value_parser;
|
||||
use eyre::Context;
|
||||
|
||||
pub struct FuzzyClone;
|
||||
@@ -201,13 +202,18 @@ impl FuzzyClone {
|
||||
}),
|
||||
)?;
|
||||
} else {
|
||||
util::shell::run(&["git", "pull"], None)?;
|
||||
util::shell::run(
|
||||
&["git", "pull"],
|
||||
Some(util::shell::RunOptions {
|
||||
path: git_repo_path.clone(),
|
||||
}),
|
||||
)?;
|
||||
}
|
||||
|
||||
Ok(git_repo_path)
|
||||
}
|
||||
|
||||
fn run() -> eyre::Result<()> {
|
||||
fn run(print_dest: &bool) -> eyre::Result<()> {
|
||||
let settings = Self::get_settings()?;
|
||||
if settings.auto_update {
|
||||
println!("running auto update");
|
||||
@@ -234,10 +240,17 @@ impl FuzzyClone {
|
||||
let chosen = util::shell::run_with_input_and_output(&["fzf"], entries_str)?;
|
||||
let chosen = std::str::from_utf8(&chosen.stdout)?;
|
||||
|
||||
Self::clone(GitHubEntry::from(chosen.to_string()).ok_or(eyre::anyhow!(
|
||||
let path = Self::clone(GitHubEntry::from(chosen.to_string()).ok_or(eyre::anyhow!(
|
||||
"could not parse choice as github entry <org>/<repo>"
|
||||
))?)?;
|
||||
|
||||
if *print_dest {
|
||||
print!(
|
||||
"{}",
|
||||
path.to_str().ok_or(eyre::anyhow!("path was not found"))?
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -255,13 +268,24 @@ impl util::Cmd for FuzzyClone {
|
||||
Ok(clap::Command::new("fuzzy-clone")
|
||||
.alias("fc")
|
||||
.alias("c")
|
||||
.arg(
|
||||
clap::Arg::new("print-dest")
|
||||
.long("print-dest")
|
||||
.value_name("print-dest")
|
||||
.value_parser(value_parser!(bool))
|
||||
.num_args(0..=1)
|
||||
.require_equals(true)
|
||||
.default_missing_value("true"),
|
||||
)
|
||||
.subcommand(clap::Command::new("update")))
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
let print_dest = args.get_one::<bool>("print-dest").unwrap_or(&false);
|
||||
|
||||
match args.subcommand() {
|
||||
Some(("update", _)) => Self::update()?,
|
||||
_ => Self::run()?,
|
||||
_ => Self::run(print_dest)?,
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@@ -1,5 +1,3 @@
|
||||
use std::{borrow::Borrow, ffi::OsString};
|
||||
|
||||
pub struct Search;
|
||||
|
||||
impl util::Cmd for Search {
|
||||
@@ -12,8 +10,8 @@ impl util::Cmd for Search {
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
match args.subcommand() {
|
||||
Some((external, args)) => {
|
||||
let mut raw = args
|
||||
.get_many::<OsString>("")
|
||||
let raw = args
|
||||
.get_many::<std::ffi::OsString>("")
|
||||
.ok_or(eyre::anyhow!("please pass some args to search"))?
|
||||
.map(|s| s.as_os_str())
|
||||
.map(|s| s.to_string_lossy().to_string())
|
||||
|
0
man/.gitkeep
Normal file
0
man/.gitkeep
Normal file
13
src/init/fish.rs
Normal file
13
src/init/fish.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
pub struct Fish;
|
||||
|
||||
impl util::Cmd for Fish {
|
||||
fn cmd() -> eyre::Result<clap::Command> {
|
||||
let cmd = clap::Command::new("fish").subcommands(&[]);
|
||||
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
20
src/init/mod.rs
Normal file
20
src/init/mod.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
mod fish;
|
||||
|
||||
pub struct Init;
|
||||
|
||||
impl util::Cmd for Init {
|
||||
fn cmd() -> eyre::Result<clap::Command> {
|
||||
let cmd = clap::Command::new("init")
|
||||
.subcommands(&[fish::Fish::cmd()?])
|
||||
.subcommand_required(true);
|
||||
|
||||
Ok(cmd)
|
||||
}
|
||||
|
||||
fn exec(args: &clap::ArgMatches) -> eyre::Result<()> {
|
||||
match args.subcommand() {
|
||||
Some(("fish", args)) => fish::Fish::exec(args),
|
||||
_ => Err(eyre::anyhow!("missing command!")),
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
use util::Cmd;
|
||||
|
||||
mod init;
|
||||
mod prereqs;
|
||||
|
||||
fn main() -> eyre::Result<()> {
|
||||
@@ -10,7 +11,9 @@ fn main() -> eyre::Result<()> {
|
||||
sourcegraph::Sourcegraph::cmd()?,
|
||||
github::GitHub::cmd()?,
|
||||
stats::Stats::cmd()?,
|
||||
init::Init::cmd()?,
|
||||
])
|
||||
.subcommand_required(true)
|
||||
.get_matches();
|
||||
|
||||
match matches.subcommand() {
|
||||
@@ -19,6 +22,7 @@ fn main() -> eyre::Result<()> {
|
||||
Some(("sourcegraph", subcmd)) => sourcegraph::Sourcegraph::exec(subcmd),
|
||||
Some(("github", subcmd)) => github::GitHub::exec(subcmd),
|
||||
Some(("stats", subcmd)) => stats::Stats::exec(subcmd),
|
||||
Some(("init", subcmd)) => init::Init::exec(subcmd),
|
||||
_ => Err(eyre::anyhow!("no command selected!")),
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user