Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e996014
- Refactor completions as native runtime functions
DannyBen Aug 18, 2026
88699ab
implement default command completions
DannyBen Aug 18, 2026
6769570
avoid offering wildcard aliases as completions
DannyBen Aug 18, 2026
2e631ff
- Add Settings.enable_completions
DannyBen Aug 19, 2026
9a55f6f
add `enable_completions` to settings JSON schema
DannyBen Aug 19, 2026
a413c4d
complete flag completion implementation
DannyBen Aug 19, 2026
d39d21a
- Remove old completions implementation and self-completion installer
DannyBen Aug 19, 2026
9f4582f
- Generate `send_completions()` function natively when completions ge…
DannyBen Aug 19, 2026
b753035
- Add structured runtime completions
DannyBen Aug 19, 2026
15860f6
fix shfmt
DannyBen Aug 19, 2026
751c1f1
Merge pull request #721 from bashly-framework/refactor/completions
DannyBen Aug 19, 2026
15723e0
- Drop support for Ruby 3.2
DannyBen Aug 19, 2026
07e9fde
- Rename settings.enable_bash3_bouncer to enable_bash_version_bouncer
DannyBen Aug 19, 2026
26c4a81
remove duplicate ruby 3.3 from ci matrix
DannyBen Aug 19, 2026
f317eb6
Merge pull request #724 from bashly-framework/rename/bash_version_bou…
DannyBen Aug 19, 2026
ec5599b
- Add zsh completions wrapper
DannyBen Aug 19, 2026
85c17c2
install zsh in ci
DannyBen Aug 19, 2026
8e80afb
Merge pull request #725 from bashly-framework/add/zsh-completion
DannyBen Aug 19, 2026
f16450c
remove heredoc from completion wrappers
DannyBen Aug 19, 2026
cffb490
- Refactor completions settings
DannyBen Aug 19, 2026
f3e6505
- Make `inspect_args` sorting deterministic
DannyBen Aug 19, 2026
41f0a42
Merge pull request #726 from bashly-framework/refactor/completion-set…
DannyBen Aug 19, 2026
df47bd8
fix schema property
DannyBen Aug 19, 2026
d1deb7e
version 2.0.0.rc1
DannyBen Aug 19, 2026
1546863
- Add `start()` bash function to wrap `__complete`, initialize` and `…
DannyBen Aug 19, 2026
54c51e5
- Avoid empty argument branches in generated completions
DannyBen Aug 19, 2026
8243165
fix empty line in `start()`
DannyBen Aug 20, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:
LC_ALL: en_US.UTF-8

strategy:
matrix: { ruby: ['3.2', '3.3', '3.4', '4.0'] }
matrix: { ruby: ['3.3', '3.4', '4.0'] }

steps:
- name: Checkout code
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0

- name: Install OS dependencies
run: sudo apt-get -y install mandoc
run: sudo apt-get -y install mandoc zsh

# Rush needed for easy installation of stuff
- name: Install rush
Expand Down
2 changes: 1 addition & 1 deletion .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ inherit_gem:
- rspec.yml

AllCops:
TargetRubyVersion: 3.2
TargetRubyVersion: 3.3
SuggestExtensions: false
Exclude:
- dev/**/*
Expand Down
5 changes: 3 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ source 'https://rubygems.org'
# gem 'debug'
gem 'rspec'
gem 'rspec_approvals'
gem 'runfile', '~> 1.0', require: false
gem 'runfile-tasks', '~> 1.0', require: false
gem 'runfile', require: false
gem 'runfile-tasks', require: false
gem 'simplecov'
gem 'completely'

gemspec
3 changes: 1 addition & 2 deletions bashly.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ Gem::Specification.new do |s|
s.executables = ['bashly']
s.homepage = 'https://github.com/bashly-framework/bashly'
s.license = 'MIT'
s.required_ruby_version = '>= 3.2'
s.required_ruby_version = '>= 3.3'

s.add_dependency 'colsole', '~> 1.0'
s.add_dependency 'completely', '~> 0.8.0'
s.add_dependency 'gtx', '~> 0.1.1'
s.add_dependency 'listen', '~> 3.9'
s.add_dependency 'lp', '~> 0.2.0'
Expand Down
3 changes: 2 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ Each of these examples demonstrates one aspect or feature of bashly.
- [default-values](default-values#readme) - arguments and flags with default values
- [minus-v](minus-v#readme) - using `-v` and `-h` in your script
- [multiline](multiline#readme) - help messages with multiple lines
- [completions](completions#readme) - exposing runtime shell completions

## Advanced configuration features

- [completions-advanced](completions-advanced#readme) - configuring static, dynamic, and option-based runtime completions
- [catch-all](catch-all#readme) - a command that can receive an arbitrary number of arguments
- [catch-all-advanced](catch-all-advanced#readme) - another example for the `catch_all` option
- [catch-all-stdin](catch-all-stdin#readme) - combining `catch_all` with `stdin` to read multiple files
Expand Down Expand Up @@ -67,7 +69,6 @@ Each of these examples demonstrates one aspect or feature of bashly.
- [ini](ini#readme) - using the ini library for direct, low level access to INI files
- [yaml](yaml#readme) - using the YAML reading functions
- [colors](colors#readme) - using the color print feature
- [completions](completions#readme) - adding bash completion functionality
- [validations](validations#readme) - adding validation functions for arguments, flags or environment variables
- [hooks](hooks#readme) - adding before/after hooks
- [stacktrace](stacktrace#readme) - adding stacktrace on error
Expand Down
6 changes: 3 additions & 3 deletions examples/catch-all/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Arguments:
````shell
# This file is located at 'src/root_command.sh'.
# It contains the implementation for the 'download' command.
# The code you write here will be wrapped by a function named 'download_command()'.
# The code you write here will be wrapped by a function named 'root_command()'.
# Feel free to edit this file; your changes will persist when regenerating.
args:
- ${args[message]} = something
Expand All @@ -92,7 +92,7 @@ args:
````shell
# This file is located at 'src/root_command.sh'.
# It contains the implementation for the 'download' command.
# The code you write here will be wrapped by a function named 'download_command()'.
# The code you write here will be wrapped by a function named 'root_command()'.
# Feel free to edit this file; your changes will persist when regenerating.
args:
- ${args[message]} = something
Expand All @@ -111,7 +111,7 @@ other_args:
````shell
# This file is located at 'src/root_command.sh'.
# It contains the implementation for the 'download' command.
# The code you write here will be wrapped by a function named 'download_command()'.
# The code you write here will be wrapped by a function named 'root_command()'.
# Feel free to edit this file; your changes will persist when regenerating.
args:
- ${args[--debug]} = 1
Expand Down
1 change: 1 addition & 0 deletions examples/completions-advanced/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cli
143 changes: 143 additions & 0 deletions examples/completions-advanced/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# Advanced Runtime Completions Example

Demonstrates configured runtime completions, including static candidates,
dynamic external commands and internal functions, file and directory sources,
and the `no-space` option.

Runtime completions are enabled in `settings.yml`. Users can load the generated
wrapper for their shell with:

```bash
# Bash
source <(cli completions)

# Zsh
source <(cli completions zsh)
```

<!-- include: settings.yml src/completions_command.sh src/lib/completions.sh -->

-----

## `bashly.yml`

````yaml
name: cli
help: Advanced runtime completions example
version: 0.1.0

commands:
- name: completions
help: Generate a shell completion script
args:
- name: shell
help: Shell to generate completions for
allowed: [bash, zsh]
default: bash

- name: deploy
help: Deploy a branch
args:
- name: branch
help: Branch to deploy
required: true

# Run an external Bash command and add each output line as a candidate.
completions:
dynamic:
- git branch --format='%(refname:short)'
- name: environment
help: Environment to deploy to

# Combine literal candidates with an internal function. Prevent the shell
# from appending a space after the selected completion.
completions:
static: [staging, production]
dynamic: [completion_environments]
options: [no-space]
flags:
- long: --config
arg: file
help: Deployment configuration file

# Ask the shell to add file and directory candidates.
completions:
options: [files]
- long: --directory
arg: path
help: Deployment directory

# Ask the shell to add directory candidates only.
completions:
options: [directories]
````
## `settings.yml`

````yaml
completions: full

````

## `src/completions_command.sh`

````bash
send_completions "${args[shell]}"

````

## `src/lib/completions.sh`

````bash
completion_environments() {
printf 'development\nstaging\n'
}

````


## Output

### `$ ./cli completions | head -n3`

````shell
_cli_completions() {
local completion_command="${COMP_WORDS[0]}"
local completion_current="${COMP_WORDS[COMP_CWORD]:-}"


````

### `$ ./cli __complete ""`

````shell
completions
deploy
:options=


````

### `$ ./cli __complete deploy main st`

````shell
staging
:options=no-space


````

### `$ ./cli __complete deploy --config ""`

````shell
:options=files


````

### `$ ./cli __complete deploy --directory ""`

````shell
:options=directories


````
1 change: 1 addition & 0 deletions examples/completions-advanced/settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
completions: full
50 changes: 50 additions & 0 deletions examples/completions-advanced/src/bashly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: cli
help: Advanced runtime completions example
version: 0.1.0

commands:
- name: completions
help: Generate a shell completion script
args:
- name: shell
help: Shell to generate completions for
allowed: [bash, zsh]
default: bash

- name: deploy
help: Deploy a branch
args:
- name: branch
help: Branch to deploy
required: true

# Run an external Bash command and add each output line as a candidate.
completions:
dynamic:
- git branch --format='%(refname:short)'
- name: environment
help: Environment to deploy to

# Combine literal candidates with an internal function. Prevent the shell
# from appending a space after the selected completion.
completions:
static: [staging, production]
dynamic: [completion_environments]
options: [no-space]

flags:
- long: --config
arg: file
help: Deployment configuration file

# Ask the shell to add file and directory candidates.
completions:
options: [files]

- long: --directory
arg: path
help: Deployment directory

# Ask the shell to add directory candidates only.
completions:
options: [directories]
1 change: 1 addition & 0 deletions examples/completions-advanced/src/completions_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
send_completions "${args[shell]}"
1 change: 1 addition & 0 deletions examples/completions-advanced/src/deploy_command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
inspect_args
3 changes: 3 additions & 0 deletions examples/completions-advanced/src/lib/completions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
completion_environments() {
printf 'development\nstaging\n'
}
13 changes: 13 additions & 0 deletions examples/completions-advanced/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -x

bashly generate

### Try Me ###

./cli completions | head -n3
./cli __complete ""
./cli __complete deploy main st
./cli __complete deploy --config ""
./cli __complete deploy --directory ""
2 changes: 1 addition & 1 deletion examples/completions/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
cli
cli
Loading