Skip to content
This repository was archived by the owner on Aug 15, 2022. It is now read-only.

kd: add interactive mode for "credential create" - #9672

Merged
rjeczalik merged 8 commits into
masterfrom
kd-credentials
Nov 26, 2016
Merged

kd: add interactive mode for "credential create"#9672
rjeczalik merged 8 commits into
masterfrom
kd-credentials

Conversation

@rjeczalik

Copy link
Copy Markdown
Contributor

depends on #9666

@rjeczalik rjeczalik added the wip label Nov 22, 2016
@rjeczalik
rjeczalik force-pushed the kd-credentials branch 5 times, most recently from ffdae38 to 2e7c62a Compare November 24, 2016 07:47
M map[string]interface{} `kloud:"someMap"`
E FooEnum `json:"enums" kloud:"someEnums"`
File []byte `kloud:",secret"`
N int `kloud:",readOnly"`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acrostic?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, just one-letter names due to laziness - n is usually int, s is usually string etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j/k


var titler = strings.NewReplacer("_", " ")

func title(s string) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about:

var re = regexp.MustCompile(`(\s*[[:upper:]]+|_)`)

func title(s string) string {
	titleF := func(match string) string {
		if rs := []rune(match); unicode.IsLower(rs[len(rs)-1]) {
			// Format matches like AAAAa -> AAA Aa.
			match = string(rs[:len(rs)-2]) + " " + string(rs[len(rs)-2:])
		}
		return " " + strings.Trim(match, "_ ")
	}

	return strings.Title(strings.TrimSpace(re.ReplaceAllStringFunc(s, titleF)))
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ping. Merging for now.

I find it harder to reason as in your version there's more "magic" behind regexp functors.

However if you find a use-case that existing impl is not enough, feel encouraged to send PR with your version.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of this line. After some thought - my solution has quite similar level of complexity so lets left this as is.

@rjeczalik
rjeczalik merged commit b62e96a into master Nov 26, 2016
@rjeczalik
rjeczalik deleted the kd-credentials branch November 26, 2016 11:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants