-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #145 from suganyasuven/test-cli
Intercept the completion script inside bal shell script
- Loading branch information
Showing
15 changed files
with
76 additions
and
364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
group=org.ballerinalang | ||
version=1.3.2-SNAPSHOT | ||
version=1.3.2-build1 | ||
ballerinaJreVersion=0.8.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Get the file path based on OS type | ||
if [[ "$OSTYPE" == "linux-gnu"* ]]; then | ||
dists_path=/usr/lib/ballerina/distributions | ||
elif [[ "$OSTYPE" == "darwin"* ]]; then | ||
dists_path=/Library/Ballerina/distributions | ||
fi | ||
|
||
_bal_completions() | ||
{ | ||
balCommands="-v --version add build clean dist doc format help new pull push run test update version" | ||
dist="list pull remove update use" | ||
|
||
# Get current ballerina version | ||
if test -f "$HOME/.ballerina/ballerina-version"; then | ||
bal_version=$(cat $HOME/.ballerina/ballerina-version) | ||
else | ||
bal_version=$(cat $dists_path/ballerina-version) | ||
fi | ||
|
||
file_path=$dists_path/$bal_version/resources/command-completion/command-completion.csv | ||
|
||
if test -f "$file_path"; then | ||
# Read the optional flags from command-completion file | ||
while IFS=, read -r cmdname flags | ||
do | ||
if [[ "${COMP_WORDS[1]}" = "$cmdname" ]]; then | ||
flags_arr="$flags" | ||
elif [[ "$cmdname" == "bal" ]]; then | ||
balCommands="$flags" | ||
fi | ||
done < <(tail -n +2 $file_path) | ||
fi | ||
|
||
if [[ "$COMP_CWORD" == "1" ]]; then | ||
COMPREPLY=($(compgen -W "$balCommands -h --help" -- "${COMP_WORDS[$COMP_CWORD]}")) | ||
return | ||
else | ||
if [[ ("${COMP_WORDS[1]}" = "dist") ]]; then | ||
COMPREPLY=($(compgen -W "$dist -h --help" "${COMP_WORDS[$COMP_CWORD]}")) | ||
return | ||
elif [[ "${COMP_WORDS[$COMP_CWORD]}" =~ ^\-.* ]] && [ -f "$file_path" ]; then | ||
# If last word has - we will suggest flags. | ||
COMPREPLY=($(compgen -W "${flags_arr[@]} -h --help" -- "${COMP_WORDS[$COMP_CWORD]}")) | ||
return | ||
fi | ||
fi | ||
} | ||
|
||
complete -o bashdefault -o default -F _bal_completions bal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 0 additions & 80 deletions
80
src/main/java/org/ballerinalang/command/cmd/BashCommand.java
This file was deleted.
Oops, something went wrong.
78 changes: 0 additions & 78 deletions
78
src/main/java/org/ballerinalang/command/cmd/CompletionCommand.java
This file was deleted.
Oops, something went wrong.
82 changes: 0 additions & 82 deletions
82
src/main/java/org/ballerinalang/command/cmd/ZshCommand.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.