Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 36 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,19 @@ jobs:

- name: Clone dependencies
shell: bash
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
shell: bash
Expand Down Expand Up @@ -67,8 +78,19 @@ jobs:
path: loop_cli

- name: Clone dependencies
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
run: |
Expand Down Expand Up @@ -108,8 +130,19 @@ jobs:
path: loop_cli

- name: Clone dependencies
env:
BRANCH: ${{ github.head_ref || github.ref_name }}
run: |
git clone --depth 1 https://github.com/gitkb/loop_lib.git
for repo in loop_lib; do
if git clone --depth 1 -b "$BRANCH" "https://github.com/gitkb/${repo}.git" 2>/dev/null; then
echo "Cloned ${repo}@${BRANCH}"
elif git clone --depth 1 "https://github.com/gitkb/${repo}.git"; then
echo "Branch ${BRANCH} not found for ${repo}; falling back to default branch"
else
echo "::error::Failed to clone ${repo}"
exit 1
fi
done

- name: Create workspace Cargo.toml
run: |
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ Add aliases to your global config:
loop --add-aliases-to-global-looprc
```

loop runs commands without a shell, so an alias value is split into words
(POSIX quoting, nothing expanded or run) that replace the program. An alias
`ll="ls -la | less"` therefore runs `ls` with the arguments `-la`, `|` and
`less`. For pipes and `&&`, ask for a shell:

```bash
loop sh -c 'ls -la | less'
```

### Combining with Other Tools

```bash
Expand All @@ -230,7 +239,8 @@ let config = LoopConfig {
..Default::default()
};

let results = run(&["npm", "test"], &config)?;
// The program and its arguments, run as given (no shell)
run(&config, &["npm".to_string(), "test".to_string()])?;
```

See [loop_lib documentation](../loop_lib/) for details.
Expand Down
8 changes: 3 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::{CommandFactory, Parser};
use colored::*;
use loop_lib::{expand_directories, parse_config, run, LoopConfig};
use loop_lib::{display_command, expand_directories, parse_config, run, LoopConfig};
use std::path::PathBuf;

#[derive(Parser)]
Expand Down Expand Up @@ -50,15 +50,13 @@ fn main() -> Result<()> {
std::process::exit(0);
}

let command = cli.command.join(" ");

// Parse the .meta file
let absolute_path = std::env::current_dir()?.join(&config_path);

if cli.verbose {
println!("{}", "Verbose mode enabled".green());
println!("\nResolved config file path: {}", absolute_path.display());
println!("Executing command: {command}");
println!("Executing command: {}", display_command(&cli.command));
}

let mut config = if config_path.exists() {
Expand All @@ -85,7 +83,7 @@ fn main() -> Result<()> {
config.directories = dirs;
}

run(&config, &command)?;
run(&config, &cli.command)?;

Ok(())
}
Loading