prep for putting repo on GH
Some checks failed
test / test (macos-latest) (push) Has been cancelled
test / test (ubuntu-latest) (push) Has been cancelled
test / test (windows-latest) (push) Has been cancelled

This commit is contained in:
Josh Thomas 2024-12-14 14:01:03 -06:00
parent 51064de6ec
commit 7000d60fde
10 changed files with 60 additions and 161 deletions

View file

@ -1,38 +0,0 @@
name: test
on:
pull_request:
push:
branches: [main]
workflow_call:
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
FORCE_COLOR: "1"
PYTHONUNBUFFERED: "1"
UV_VERSION: "0.4.x"
jobs:
test:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- name: Install uv
run: curl -LsSf https://astral.sh/uv/install.sh | sh
- name: Install Rust toolchain
uses: https://github.com/moonrepo/setup-rust@v1
- name: Install Protoc
uses: https://git.joshthomas.dev/mirrors/setup-protoc@v3
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

33
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,33 @@
name: test
on:
pull_request:
push:
branches: [main]
workflow_call:
concurrency:
group: test-${{ github.head_ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- macos-latest
- ubuntu-latest
- windows-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose

95
Cargo.lock generated
View file

@ -51,15 +51,6 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "atomic"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d818003e740b63afc82337e3160717f4f63078720a810b7b903e70a5d1d2994"
dependencies = [
"bytemuck",
]
[[package]]
name = "autocfg"
version = "1.4.0"
@ -72,12 +63,6 @@ version = "2.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de"
[[package]]
name = "bytemuck"
version = "1.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b37c88a63ffd85d15b406896cc343916d7cf57838a847b3a6f2ca5d39a5695a"
[[package]]
name = "cfg-if"
version = "1.0.0"
@ -173,20 +158,6 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "figment"
version = "0.10.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cb01cd46b0cf372153850f4c6c272d9cbea2da513e07538405148f95bd789f3"
dependencies = [
"atomic",
"pear",
"serde",
"toml",
"uncased",
"version_check",
]
[[package]]
name = "getrandom"
version = "0.2.15"
@ -220,12 +191,6 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "inlinable_string"
version = "0.1.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8fae54786f62fb2918dcfae3d568594e50eb9b5c25bf04371af6fe7516452fb"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
@ -305,29 +270,6 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "pear"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bdeeaa00ce488657faba8ebf44ab9361f9365a97bd39ffb8a60663f57ff4b467"
dependencies = [
"inlinable_string",
"pear_codegen",
"yansi",
]
[[package]]
name = "pear_codegen"
version = "0.2.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bab5b985dc082b345f812b7df84e1bef27e7207b39e448439ba8bd69c93f147"
dependencies = [
"proc-macro2",
"proc-macro2-diagnostics",
"quote",
"syn",
]
[[package]]
name = "proc-macro2"
version = "1.0.92"
@ -337,19 +279,6 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "proc-macro2-diagnostics"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8"
dependencies = [
"proc-macro2",
"quote",
"syn",
"version_check",
"yansi",
]
[[package]]
name = "quote"
version = "1.0.37"
@ -428,12 +357,11 @@ dependencies = [
]
[[package]]
name = "shadow-rs"
name = "shadow-cli"
version = "0.1.0"
dependencies = [
"clap",
"dirs",
"figment",
"serde",
"temp-env",
"tempfile",
@ -560,15 +488,6 @@ dependencies = [
"winnow",
]
[[package]]
name = "uncased"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e1b88fcfe09e89d3866a5c11019378088af2d24c3fbd4f0543f96b479ec90697"
dependencies = [
"version_check",
]
[[package]]
name = "unicode-ident"
version = "1.0.14"
@ -581,12 +500,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "version_check"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
@ -740,9 +653,3 @@ checksum = "36c1fec1a2bb5866f07c25f68c26e565c4c200aebb96d7e55710c19d3e8ac49b"
dependencies = [
"memchr",
]
[[package]]
name = "yansi"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"

View file

@ -1,12 +1,11 @@
[package]
name = "shadow-rs"
name = "shadow-cli"
version = "0.1.0"
edition = "2021"
[dependencies]
clap = { version = "4.5", features = ["derive", "env"] }
dirs = "5.0"
figment = { version = "0.10", features = ["env", "toml"] }
serde = { version = "1.0", features = ["derive"] }
thiserror = "2.0"
toml = "0.8"
@ -16,5 +15,5 @@ temp-env = "0.3"
tempfile = "3.14"
[[bin]]
name = "shadow"
name = "shdw"
path = "src/main.rs"

View file

@ -43,7 +43,6 @@ lint:
cargo fmt
cargo clippy
test:
#!/usr/bin/env bash
set -euo pipefail

View file

@ -7,4 +7,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View file

@ -1,6 +1,6 @@
# shadow
# shdw
A CLI tool to manage your shell aliases through symlinks.
A CLI tool to manage your shell aliases.
## Requirements
@ -13,37 +13,37 @@ A CLI tool to manage your shell aliases through symlinks.
Install directly from the repository:
```bash
cargo install --git https://git.joshthomas.dev/josh/shadow
cargo install --git https://github.com/joshuadavidthomas/shdw
```
## Usage
### Adding a shadow
### Adding an alias
Create a new alias by shadowing an existing command:
```bash
shadow add ls exa # 'ls' will now execute 'exa'
shdw add ls exa # 'ls' will now execute 'exa'
```
You can specify a custom installation directory:
```bash
shadow add --bin-path ~/.local/bin ls exa
shdw add --bin-path ~/.local/bin ls exa
```
### Removing a shadow
### Removing an alias
Remove an existing shadow to restore the original command:
Remove an existing alias to restore the original command:
```bash
shadow remove ls
shdw remove ls
```
### Listing shadows
### Listing aliases
View all active shadows:
View all active aliases:
```bash
shadow list
shdw list
```

View file

@ -7,11 +7,11 @@ use std::path::PathBuf;
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Add a new shadow
/// Add a new alias
Add(Add),
/// Remove a shadow
/// Remove an alias
Remove(Remove),
/// List all shadows
/// List all aliases
List(List),
}
@ -27,7 +27,7 @@ impl Commands {
#[derive(Clone, Debug, Parser)]
pub struct Add {
/// Original command to shadow
/// Original command to alias
original: String,
/// Replacement command
replacement: String,
@ -39,7 +39,7 @@ pub struct Add {
impl Add {
pub fn execute(&self, mut config: Config) -> ExitCode {
if config.shadows().contains(&self.original) {
eprintln!("Command already shadowed: {}", self.original);
eprintln!("Command already aliased: {}", self.original);
return ExitCode::DuplicateCommand;
}
@ -58,7 +58,7 @@ impl Add {
match config.add(shadow) {
Ok(()) => {
println!("Added shadow: {}", self.original);
println!("Added alias: {}", self.original);
ExitCode::Success
}
Err(e) => {
@ -71,7 +71,7 @@ impl Add {
#[derive(Clone, Debug, Parser)]
pub struct Remove {
/// Command to un-shadow
/// Command to un-alias
original: String,
/// Directory containing the symlink
#[arg(long)]
@ -95,7 +95,7 @@ impl Remove {
match config.remove(&self.original) {
Ok(()) => {
println!("Removed shadow: {}", self.original);
println!("Removed alias: {}", self.original);
ExitCode::Success
}
Err(e) => {
@ -112,7 +112,7 @@ pub struct List;
impl List {
pub fn execute(&self, config: Config) -> ExitCode {
match config.shadows().is_empty() {
true => println!("No shadows configured"),
true => println!("No aliases configured"),
false => config
.shadows()
.iter()

View file

@ -74,7 +74,7 @@ impl Config {
fn config_path() -> PathBuf {
dirs::config_dir()
.expect("Could not find config directory")
.join("shadow/config.toml")
.join("shdw/config.toml")
}
}

View file

@ -16,7 +16,7 @@ fn main() {
let program_name = Path::new(&args)
.file_name()
.and_then(|name| name.to_str())
.unwrap_or("shadow");
.unwrap_or("shdw");
let config = match Config::load() {
Ok(config) => config,
Err(e) => {
@ -26,7 +26,7 @@ fn main() {
};
let exit_code = match program_name {
"shadow" => Cli::execute(config),
"shdw" => Cli::execute(config),
command => Cli::execute_shadowed(config, command),
};