Allow to specify template when running dagger project init
Adds the ability to select a template which will create a new file in the CWD with the template name. Templates present in the "cmd/dagger/project/templates" directory are automatically embedded in the dagger binary when building and then listed in the `dagger project init` help output. Usage: dagger project init -t <template_name> One idea that we had while pairing on this is to eventually try improving this UX by extending the `dagger project` command by adding sub-commands like `dagger project templates [list, new, output, ...]`. Pair: gerhard Signed-off-by: Marcos Lilljedahl <marcosnils@gmail.com>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
"test": "bats --jobs 4 --print-output-on-failure --verbose-run ."
|
||||
},
|
||||
"devDependencies": {
|
||||
"bats": "https://github.com/bats-core/bats-core#master",
|
||||
"bats": "https://github.com/bats-core/bats-core#v1.6.0",
|
||||
"bats-assert": "https://github.com/bats-core/bats-assert",
|
||||
"bats-support": "https://github.com/bats-core/bats-support"
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ setup() {
|
||||
}
|
||||
|
||||
@test "project init and update and info" {
|
||||
cd "$TEMPDIR" || exit
|
||||
cd "$TEMPDIR" || exit 1
|
||||
|
||||
"$DAGGER" project init ./ --name "github.com/foo/bar"
|
||||
test -d ./cue.mod/pkg
|
||||
@@ -39,3 +39,27 @@ setup() {
|
||||
assert_failure
|
||||
assert_output --partial "dagger project not found. Run \`dagger project init\`"
|
||||
}
|
||||
|
||||
|
||||
@test "project init with template" {
|
||||
cd "$TEMPDIR" || exit 1
|
||||
|
||||
if test -f ./hello.cue
|
||||
then
|
||||
echo "./hello.cue should not exist"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
run "$DAGGER" project init -t hello
|
||||
|
||||
assert_success
|
||||
|
||||
if test ! -f ./hello.cue
|
||||
then
|
||||
echo "./hello.cue file was not created by the template flag"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cd -
|
||||
diff --unified "$TEMPDIR/hello.cue" "$TESTDIR/../cmd/dagger/cmd/project/templates/hello.cue"
|
||||
}
|
||||
|
Reference in New Issue
Block a user