Skip to content

Commit

Permalink
tab completion :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles Sherk committed Nov 15, 2021
1 parent 5d4bb6c commit 2d3c0af
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ running java with the command `java -jar pdl.jar <args>`.
We also provide a script `pdl` in the `bin` directory that
runs the executable jar with the provided arguments.

#### Tab completion

We provide a bash autocomplete script in the `bin` directory.
To enable tab completion on `./bin/pdl` and `pdl`, simply source
the script `pdl-completion.bash`. You can do this by adding it to
the file `~/.bash_completion`, or whatever your preferred sourcing
method may be.

### Generating Hardware

PDL produces BSV code which can then be run via the BSV simulator,
Expand Down
26 changes: 26 additions & 0 deletions bin/pdl-completion.bash
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#/usr/bin/bash

_pdl()
{
local cur=${COMP_WORDS[COMP_CWORD]}

if [[ $cur == -* ]] ; then
local opts="--help --out --printStages --debug --portwarn --autocast --addrLockModule --reglockModule"
local fword=${COMP_WORDS[1]}
if [ $fword == "interpret" ]; then
opts="$opts --maxIterations --memoryInput"
elif [ $fword == "gen" ]; then
opts="$opts --memInit"
fi
COMPREPLY=( $( compgen -W "$opts" -- "$cur"))
else
if [ "${#COMP_WORDS[@]}" != "2" ]; then
COMPREPLY=( $( compgen -o plusdirs -f -X "!*.pdl" -- $cur ))
else
COMPREPLY=( $( compgen -W "gen typecheck parse interpret" -- "$cur"))
fi
fi
}


complete -o filenames -F _pdl ./bin/pdl pdl

0 comments on commit 2d3c0af

Please sign in to comment.