Add shell tab-completion support for flubu commands outside interactive mode
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 35/100
- Tipo de issue
- Nueva funcionalidad
- Claridad
- Bien especificado
- Estado de actividad
- Estancado
- Área
- build-system, cli
Línea de trabajo
Comienza en FlubuCommandParser y compara el flujo interactivo existente en CommandExecutorInteractive.InitializeFlubuConsole(). Rastrea cómo IScriptProperties.GetPropertiesHints(), TargetTree, FlubuConsole y las opciones de tarea [ArgKey] exponen datos de autocompletado. Se considera terminado cuando --completions devuelve los targets y las opciones coincidentes, y --setup-completions genera scripts funcionales para bash, zsh, PowerShell y fish.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
Add shell tab-completion for flubu commands in bash, zsh, PowerShell, and fish. Currently completion only works inside flubu -i interactive mode. Users running normal flubu <target> commands get no tab-completion and must rely on --help or memory.
Motivation
Modern CLIs (dotnet, gh, kubectl, docker) all support shell tab-completion. Users expect to type flubu cl<tab> and get clean completed. This is especially valuable for FlubuCore since target names are user-defined and vary per project — there's no way to know them without looking at the build script or running --help.
Proposed Implementation
1. Add a hidden --completions command
A new option in FlubuCommandParser that outputs matching completions to stdout, one per line:
flubu --completions "flubu cl"
# output:
# clean
# clean.output
flubu --completions "flubu --"
# output:
# --parallel
# --dryrun
# --noColor
# --nodeps
# --script
# --debug
This command needs to:
- Load the build script (if present) to discover targets from
TargetTree - Include all registered options from
FlubuCommandParser - Include script property hints from
IScriptProperties.GetPropertiesHints() - Match the partial input against available completions (prefix match is sufficient)
- Output matches to stdout, one per line
- Exit with code 0
2. Add --setup-completions <shell> command
Outputs the shell-specific completion script that users source once:
# Bash — add to ~/.bashrc
eval "$(flubu --setup-completions bash)"
# Zsh — add to ~/.zshrc
eval "$(flubu --setup-completions zsh)"
# PowerShell — add to $PROFILE
flubu --setup-completions pwsh | Invoke-Expression
# Fish
flubu --setup-completions fish | source
3. Shell completion scripts
Each script registers a completion function that calls flubu --completions "<current-line>" on each tab press.
Bash example:
_flubu_completions() {
local IFS=$'\n'
COMPREPLY=($(flubu --completions "${COMP_LINE}" 2>/dev/null))
}
complete -F _flubu_completions flubu
PowerShell example:
Register-ArgumentCompleter -CommandName flubu -Native -ScriptBlock {
param($wordToComplete, $commandAst, $cursorPosition)
$completions = flubu --completions "$commandAst" 2>$null
$completions -split "`n" | ForEach-Object {
[System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)
}
}
What should complete
| Input | Completes with |
|---|---|
flubu <tab> |
All target names from build script |
flubu cl<tab> |
Targets starting with "cl" (e.g., clean) |
flubu --<tab> |
Global options: --parallel, --dryrun, --noColor, --nodeps, --script, --debug |
flubu -s <tab> |
.cs files in current directory |
flubu test --<tab> |
Target-specific task options (from [ArgKey] attributes) |
Existing code to reuse
All the hint/completion data already exists and is used by flubu -i interactive mode:
- Target discovery:
CommandExecutorInteractive.InitializeFlubuConsole()already walksTargetTree - Script property hints:
IScriptProperties.GetPropertiesHints() - Task option hints:
FlubuConsoleextracts these via[ArgKey]reflection - Command hints:
GitCommands,DotnetCommands,DockerCommands,ChocolateyCommands
The --completions command just needs to reuse this data and write matches to stdout instead of rendering them in the console.
Why not migrate to System.CommandLine?
Evaluated and rejected because:
- FlubuCore targets are dynamic (discovered from user build scripts at runtime) — System.CommandLine's model expects static command trees
- Would require rewriting
FlubuCommandParserand all option definitions - System.CommandLine requires users to install
dotnet-suggestglobal tool + shell shims — heavier setup - Custom
--completionsis quite easy to implement and gives full control
Why not use McMaster's completion support?
McMaster.Extensions.CommandLineUtils has no shell completion support. Feature requests (#9, #438) were closed. The library is in maintenance mode.
- Lenguaje dominante
- C#
- Estrellas
- 937
- Forks
- 99
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de dotnetcore/FlubuCore
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
dotnetcore/FlubuCore#371 ·
-
Dificultad 3/5 1-2 días Aptitud para principiantes 55/100
dotnetcore/FlubuCore#369 ·
-
怎么能让他不输出任务执行消息,测试了所有都没用Abierto
Dificultad 5/5 Más de una semana Aptitud para principiantes 18/100
dotnetcore/FlubuCore#367 ·
-
FlubuCore WebAPI LoginAbierto
Dificultad 3/5 1-2 días Aptitud para principiantes 20/100
dotnetcore/FlubuCore#365 ·
-
enhancement help wanted
Dificultad 5/5 Más de una semana Aptitud para principiantes 25/100
dotnetcore/FlubuCore#333 ·
Todos los issues de dotnetcore/FlubuCore
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Los mantenedores suelen responder en 1 día
-
Attention: a throwing permission check on one contributor fails the whole aggregation requestAbiertoready-for-agent size:S status:todo
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
elsa-workflows/elsa-foundation#2830 ·
Los mantenedores suelen responder en 1 día
-
Review - Maintainer WG-Maintainers-Build
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
PowerShell/PowerShell#28220 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
area: docs eco: dotnet good first issue help wanted lane: free-agent roadmap size: XS type: docs
Dificultad 2/5 Menos de una hora Aptitud para principiantes 72/100
arminazimi/evergreen#377 ·
Los mantenedores suelen responder en 1 día
-
documentation good first issue
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
Los mantenedores suelen responder en 1 día