template / commit
Mostly readme updates.
.gitignore | 1 + README.md | 95 +++++++++++++++++++++++++++++++++++++++++++++++--------------- config.go | 2 +- 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/.gitignore b/.gitignore index 86785ba..c47543f 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ +.git template.exe diff --git a/README.md b/README.md index 52ffa58..122ccc5 100644 --- a/README.md +++ b/README.md @@ -6,10 +6,54 @@ template ## Description -This is a hackathon project that I used to learn Go (golang). -This CLI creates files and folders with generated names. +This CLI creates files and folders with generated names, for example `2022-09-26-fhl-2023.md` (generator on September 26, 2023, with the project name "fhl-2023"). It's also possible to control the contents of the files: you can specify a template file or an inline template to set the file contents. +This is a hackathon project that I used to learn Go (golang). + +### Sample tool config + +This is one of the profiles that comes with the tool. + +```yaml +profiles: + - isdefault: false + name: daily + description: Creates a MD file in c:\work\daily-notes folder in the format YYYY-MM-DD[-vX].md + path: ~/Dropbox/DailyNotes + type: file + namepatterns: + - '{{$version := getVersion}}{{.Year}}-{{.Month}}-{{.Day}}{{if (gt $version 1)}}v{{$version}}{{end}}.md' + postscripts: + - code . "{{.Path}}" + scriptshell: pwsh + os: "" + filetemplatepath: "" + filetemplate: |- + # {{.Year}}-{{.Month}}-{{.Day}} + + Today's notes + + ## Todo + + 1. [ ] Check email + 2. [ ] Check chat + 3. [ ] Check calendar + 4. [ ] Check yesterday's notes + 5. [ ] Have fun! +``` + +Using the above configuration: +```pwsh +> template daily +Config loaded from 'C:\Users\fuzzy\.template.yaml' +Profile: daily +Creating file 'C:\Users\fuzzy\Dropbox\DailyNotes\2022-09-26.md' from template string +Executing post script: pwsh -c code . "C:\Users\fuzzy\Dropbox\DailyNotes\2022-09-26.md" +``` + +This will cause VSCode to open the `~\Dropbox\DailyNotes` folder as a workspace, and the newly-created file `2022-09-26.md` will be opened as well. + ## Requirements The application requires [go](https://en.wikipedia.org/wiki/Go_(programming_language)). You can download the installer [here](https://go.dev/doc/install). @@ -24,7 +68,14 @@ The default profiles use [PowerShell Core](https://github.com/PowerShell/PowerSh ## Installation -`go install` +To install the `template` application and default templates, you have 2 options: + +1. `.\scripts\clean-install.ps1` +2. In VSCode, run the "Clean install" job + +Both operations do the same thing. + +Note: the above installation will remove any local template/config changes you may have made. ### Running after installation @@ -32,26 +83,12 @@ The default profiles use [PowerShell Core](https://github.com/PowerShell/PowerSh - `template blog` OR `template --profile blog` OR `template -p blog` - creates a date-stamped MD file in ~/Dropbox/Blog, opens in VSCode - `template daily topic` OR `template --profile daily --name topic` OR `template -p daily -n topic` - creates a templated date-stamped MD file with `topic` in its name in ~/Dropbox/DailyNotes, opens in VSCode -### Install dev loop - -Here is a way to install the app, clear out the local config, and run the app: - -1. Open project in VSCode -2. Run the "Clean install" task from "Run and Debug" view +### Dev loop -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/fuzzy-rp/template/-/settings/integrations) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) +1. `go mod tidy` - installs dependencies +2. `go run . $profile $name` - runs profile `$profile` and uses `$name` to create a new file/folder +3. `go test` - runs tests +4. `go install` - installs template locally ## Support @@ -82,3 +119,17 @@ MIT license. This was a hackathon project to learn Go. I'm going to be using this tool and upgrading it as I see fit. + +## Integrate with your tools + +- [ ] [Set up project integrations](https://gitlab.com/fuzzy-rp/template/-/settings/integrations) + +## Test and Deploy + +Use the built-in continuous integration in GitLab. + +- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) +- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) +- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) +- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) +- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) diff --git a/config.go b/config.go index 04eb025..24c01d1 100644 --- a/config.go +++ b/config.go @@ -54,7 +54,7 @@ func defaultConfig() Config { Profiles: []Profile{ { Name: "daily", - Description: "Creates a MD file in c:\\work\\daily-notes folder in the format YYYY-MM-DD[-vX].md", + Description: "Creates a MD file in ~/Dropbox/DailyNotes folder in the format YYYY-MM-DD[-vX].md", Path: "~/Dropbox/DailyNotes", Type: FileType, NamePatterns: []string{