Skip to content

Commit

Permalink
Merge pull request #17 from essentialkaos/develop
Browse files Browse the repository at this point in the history
Version 0.6.0
  • Loading branch information
andyone authored May 26, 2017
2 parents dd80084 + 16a9e85 commit d42bb1e
Show file tree
Hide file tree
Showing 5 changed files with 132 additions and 31 deletions.
21 changes: 21 additions & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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_).
54 changes: 54 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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)]

24 changes: 24 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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 .

########################################################################################
Expand All @@ -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 {} \;
Expand Down
60 changes: 31 additions & 29 deletions knfgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,46 +12,46 @@ 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

// ////////////////////////////////////////////////////////////////////////////////// //

func main() {
args, errs := arg.Parse(argMap)
args, errs := options.Parse(optMap)

if len(errs) != 0 {
for _, err := range errs {
Expand All @@ -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
}
Expand All @@ -94,7 +94,7 @@ func configureUI() {
}
}

if arg.GetB(ARG_NO_COLOR) {
if options.GetB(OPT_NO_COLOR) {
fmtc.DisableColors = true
}

Expand Down Expand Up @@ -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()
}
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit d42bb1e

Please sign in to comment.