choria-io / appbuilder

Tool to create friendly wrapping command lines over operations tools
Apache License 2.0
105 stars 4 forks source link

Add a scaffolding command #137

Closed ripienaar closed 1 year ago

ripienaar commented 1 year ago

We should be able to scaffold many files using a command in a Tasfile, flags, arguments and other relavant details like working dir and app dir should be set as context and all files should be template parsed

name: scaffold
description: Creates an skeleton thing
arguments:
   - name: name
     description: The directory to create
     required: true

type: scaffold

# required, should not exist
target: /tmp/{{ .Arguments.Name }}

# where to find a directory full of files to base the scaffold from, supports templates
source_directory: /..../scaffold.source

# for smaller use cases one can instead specify the source in yaml here (ugh)
source:
  x.txt: |
    Content here ....
  foo: # a directory called foo with a file in it
    bar.txt: |
      Content here ...

# Post processes files matching with filepath.Match using shell commands
# if {} is in the string its replaced with path, if not path is appended as argument
post:
  - "*.go": gofmt -w {}
  - "*.go": goimports -w