aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Christopher Vogt <oss.nsp@cvogt.org>2016-09-13 15:30:08 +0100
committerGitHub <noreply@github.com>2016-09-13 15:30:08 +0100
commit1dcb71c9584f8dd84f4e6dfa4bcc69ef3a4810de (patch)
tree432d47a1793fb93c5f7e1b6b79b52c71e05c9c8a
parentaf5d391a71a86951b6a2252e9f60eeeb0362192d (diff)
parentf8b2f559453bc3b1491e805f81db7c5920401734 (diff)
downloadcbt-1dcb71c9584f8dd84f4e6dfa4bcc69ef3a4810de.tar.gz
cbt-1dcb71c9584f8dd84f4e6dfa4bcc69ef3a4810de.tar.bz2
cbt-1dcb71c9584f8dd84f4e6dfa4bcc69ef3a4810de.zip
Merge pull request #221 from cvogt/chris3
fish completions, fix bash completions, and fix task args
-rw-r--r--README.md5
-rwxr-xr-xshell-integration/cbt-completions.bash2
-rw-r--r--shell-integration/cbt-completions.fish1
-rw-r--r--stage2/BasicBuild.scala2
-rw-r--r--stage2/Stage2.scala2
-rw-r--r--test/simple/build/build.scala2
-rw-r--r--test/test.scala6
7 files changed, 18 insertions, 2 deletions
diff --git a/README.md b/README.md
index 2f2134b..dd51fae 100644
--- a/README.md
+++ b/README.md
@@ -192,3 +192,8 @@ for f in ~/.bash_completion.d/*; do
source $f
done
```
+
+Fish shell completions
+----------------
+copy this line into your fish configuration, on OSX: /.config/fish/config.fish
+complete -c cbt -a '(cbt taskNames)'
diff --git a/shell-integration/cbt-completions.bash b/shell-integration/cbt-completions.bash
index c591321..925ba4b 100755
--- a/shell-integration/cbt-completions.bash
+++ b/shell-integration/cbt-completions.bash
@@ -5,7 +5,7 @@ __cbt()
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
- opts="$(cbt usage)"
+ opts="$(cbt taskNames)"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
}
diff --git a/shell-integration/cbt-completions.fish b/shell-integration/cbt-completions.fish
new file mode 100644
index 0000000..6e543fb
--- /dev/null
+++ b/shell-integration/cbt-completions.fish
@@ -0,0 +1 @@
+complete -c cbt -a (cbt taskNames)
diff --git a/stage2/BasicBuild.scala b/stage2/BasicBuild.scala
index 410d68f..b2bb72b 100644
--- a/stage2/BasicBuild.scala
+++ b/stage2/BasicBuild.scala
@@ -25,6 +25,8 @@ trait BaseBuild extends DependencyImplementation with BuildInterface with Trigge
final def projectDirectory: File = lib.realpath(context.projectDirectory)
assert( projectDirectory.exists, "projectDirectory does not exist: " ++ projectDirectory.string )
final def usage: String = lib.usage(this.getClass, show)
+
+ final def taskNames: String = lib.taskNames(this.getClass).sorted.mkString("\n")
// ========== meta data ==========
diff --git a/stage2/Stage2.scala b/stage2/Stage2.scala
index 9ef96fa..3d5c244 100644
--- a/stage2/Stage2.scala
+++ b/stage2/Stage2.scala
@@ -32,7 +32,7 @@ object Stage2 extends Stage2Base{
val context: Context = ContextImplementation(
args.cwd,
args.cwd,
- args.args.drop( taskIndex ).toArray,
+ args.args.drop( taskIndex +1 ).toArray,
logger.enabledLoggers.toArray,
logger.start,
args.cbtHasChanged,
diff --git a/test/simple/build/build.scala b/test/simple/build/build.scala
index cf41c8c..66ee392 100644
--- a/test/simple/build/build.scala
+++ b/test/simple/build/build.scala
@@ -35,4 +35,6 @@ class Build(val context: cbt.Context) extends BaseBuild{
"ai.x" %% "lens" % "1.0.0"
)
)
+
+ def printArgs = context.args.mkString(" ")
}
diff --git a/test/test.scala b/test/test.scala
index 65790f8..4f332ea 100644
--- a/test/test.scala
+++ b/test/test.scala
@@ -197,6 +197,12 @@ object Main{
compile("../examples/uber-jar-example")
{
+ val res = runCbt("simple", Seq("printArgs","1","2","3"))
+ assert(res.exit0)
+ assert(res.out == "1 2 3", res.out)
+ }
+
+ {
val res = runCbt("forgot-extend", Seq("run"))
assert(!res.exit0)
assert(res.err contains "Build cannot be cast to cbt.BuildInterface", res.err)