diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 0000000..2a651a3 --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,21 @@ +# Contributing Guidelines + +Contributing guidelines for open-source EK projects. + +**IMPORTANT! Contribute your code only if you have an excellent understanding of project idea and all existing code base. Otherwise, a nicely formatted issue will be more helpful to us.** + +### Issues + +1. Provide product version where the problem was found; +2. Provide info about your environment; +3. Provide detailed info about your problem; +4. Provide steps to reproduce the problem; +5. Provide actual and expected results. + +### Code + +1. Check your code **before** creating pull request; +2. If tests are present in a project, add tests for your code; +3. Add inline documentation for your code; +4. Apply code style used throughout the project; +5. Create your pull request to `develop` branch (_pull requests to other branches are not allowed_). diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md new file mode 100644 index 0000000..6479c46 --- /dev/null +++ b/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,54 @@ +_Before opening an issue, search for similar bug reports or feature requests on GitHub Issues. If yes, please add a_ 👍 _reaction to the existing issue. If no similar issue can be found, fill out either the "Bug Report" or the "Feature Request" section below. Erase the other section and everything on and above this line._ + +### Bug report + +**System info:** + +* **Version used (`knfgen -v`):** +* **OS (`cat /etc/*-release`):** +* **Kernel (`uname -a`):** +* **Go version (`go version`):** +* **Install tools:** + +**System info:** + +1. [First Step] +2. [Second Step] +3. [and so on...] + +**Expected behavior:** + +[What you expected to happen] + +**Actual behavior:** + +[What actually happened] + +**Additional info:** + +[Include gist of relevant config, logs, etc.] + +Please run those if possible and link them from a [gist](http://gist.github.com). + +--- + +### Feature Request + +Opening a feature request kicks off a discussion. Requests may be closed if we're not actively planning to work on them. + +**Proposal:** + +[Description of the feature] + +**Current behavior:** + +[What currently happens] + +**Desired behavior:** + +[What you would like to happen] + +**Use case:** + +[Why is this important (helps with prioritizing requests)] + diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..e7814b8 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ +### What did you implement: + +Closes #XXXXX + +### How did you implement it: + +... + +### How can we verify it: + +... + +### TODO's: + +- [ ] Write tests +- [ ] Write documentation +- [ ] Check that there aren't other open pull requests for the same issue/feature +- [ ] Format your source code by `make fmt` +- [ ] Provide verification config / commands +- [ ] Enable "Allow edits from maintainers" for this PR +- [ ] Update the messages below + +**Is this ready for review?:** No +**Is it a breaking change?:** No diff --git a/Makefile b/Makefile index 975d4dc..5f08f01 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ######################################################################################## -# This Makefile generated by GoMakeGen 0.5.0 using next command: +# This Makefile generated by GoMakeGen 0.6.0 using next command: # gomakegen --metalinter . ######################################################################################## @@ -16,7 +16,7 @@ knfgen: deps: git config --global http.https://pkg.re.followRedirects true - go get -d -v pkg.re/essentialkaos/ek.v8 + go get -d -v pkg.re/essentialkaos/ek.v9 fmt: find . -name "*.go" -exec gofmt -s -w {} \; diff --git a/knfgen.go b/knfgen.go index 16a9cc3..a3ba69a 100644 --- a/knfgen.go +++ b/knfgen.go @@ -12,38 +12,38 @@ import ( "strconv" "strings" - "pkg.re/essentialkaos/ek.v8/arg" - "pkg.re/essentialkaos/ek.v8/env" - "pkg.re/essentialkaos/ek.v8/fmtc" - "pkg.re/essentialkaos/ek.v8/fmtutil" - "pkg.re/essentialkaos/ek.v8/fsutil" - "pkg.re/essentialkaos/ek.v8/knf" - "pkg.re/essentialkaos/ek.v8/mathutil" - "pkg.re/essentialkaos/ek.v8/usage" + "pkg.re/essentialkaos/ek.v9/env" + "pkg.re/essentialkaos/ek.v9/fmtc" + "pkg.re/essentialkaos/ek.v9/fmtutil" + "pkg.re/essentialkaos/ek.v9/fsutil" + "pkg.re/essentialkaos/ek.v9/knf" + "pkg.re/essentialkaos/ek.v9/mathutil" + "pkg.re/essentialkaos/ek.v9/options" + "pkg.re/essentialkaos/ek.v9/usage" ) // ////////////////////////////////////////////////////////////////////////////////// // const ( APP = "KNFGen" - VER = "0.5.0" + VER = "0.6.0" DESC = "Utility for generating Golang const code for KNF configs" ) const ( - ARG_SEPARATORS = "s:separators" - ARG_NO_COLOR = "nc:no-color" - ARG_HELP = "h:help" - ARG_VER = "v:version" + OPT_SEPARATORS = "s:separators" + OPT_NO_COLOR = "nc:no-color" + OPT_HELP = "h:help" + OPT_VER = "v:version" ) // ////////////////////////////////////////////////////////////////////////////////// // -var argMap = arg.Map{ - ARG_SEPARATORS: {Type: arg.BOOL}, - ARG_NO_COLOR: {Type: arg.BOOL}, - ARG_HELP: {Type: arg.BOOL, Alias: "u:usage"}, - ARG_VER: {Type: arg.BOOL, Alias: "ver"}, +var optMap = options.Map{ + OPT_SEPARATORS: {Type: options.BOOL}, + OPT_NO_COLOR: {Type: options.BOOL}, + OPT_HELP: {Type: options.BOOL, Alias: "u:usage"}, + OPT_VER: {Type: options.BOOL, Alias: "ver"}, } var rawOutput = false @@ -51,7 +51,7 @@ var rawOutput = false // ////////////////////////////////////////////////////////////////////////////////// // func main() { - args, errs := arg.Parse(argMap) + args, errs := options.Parse(optMap) if len(errs) != 0 { for _, err := range errs { @@ -63,12 +63,12 @@ func main() { configureUI() - if arg.GetB(ARG_VER) { + if options.GetB(OPT_VER) { showAbout() return } - if arg.GetB(ARG_HELP) || len(args) == 0 { + if options.GetB(OPT_HELP) || len(args) == 0 { showUsage() return } @@ -94,7 +94,7 @@ func configureUI() { } } - if arg.GetB(ARG_NO_COLOR) { + if options.GetB(OPT_NO_COLOR) { fmtc.DisableColors = true } @@ -147,7 +147,7 @@ func renderConfig(config *knf.Config) { ) } - if arg.GetB(ARG_SEPARATORS) && sectionIndex < sectionsTotal-1 { + if options.GetB(OPT_SEPARATORS) && sectionIndex < sectionsTotal-1 { fmtc.NewLine() } } @@ -177,29 +177,31 @@ func getFormatString(maxSize int) string { // printError prints error message to console func printError(f string, a ...interface{}) { - fmtc.Printf("{r}"+f+"{!}\n", a...) + fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) } // printError prints warning message to console func printWarn(f string, a ...interface{}) { - fmtc.Printf("{y}"+f+"{!}\n", a...) + fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) } // ////////////////////////////////////////////////////////////////////////////////// // +// showUsage show usage info func showUsage() { info := usage.NewInfo("", "config-file") - info.AddOption(ARG_SEPARATORS, "Add new lines between sections") - info.AddOption(ARG_NO_COLOR, "Disable colors in output") - info.AddOption(ARG_HELP, "Show this help message") - info.AddOption(ARG_VER, "Show version") + info.AddOption(OPT_SEPARATORS, "Add new lines between sections") + info.AddOption(OPT_NO_COLOR, "Disable colors in output") + info.AddOption(OPT_HELP, "Show this help message") + info.AddOption(OPT_VER, "Show version") info.AddExample("app.conf", "Generate copy-paste code for app.conf") info.Render() } +// showAbout show info about version func showAbout() { about := &usage.About{ App: APP,