Skip to content

Commit

Permalink
cmd/snap: allow option descriptions to start with the command
Browse files Browse the repository at this point in the history
Before this change, option descriptions that were slightly
self-referential and started with the command name would trigger the
linter warning:

    2018/12/12 19:51:16.123791 main.go:152: description of advise-snap's "from-apt" is lowercase: "advise-snap vil tale med apt via en apt-hook"

this change makes it so that an option description can start with the
command without raising a warning.

It also fixes that particular option to be more correct, and
discourages this particular translation.
  • Loading branch information
chipaca committed May 13, 2019
1 parent c9c7c97 commit 8a2c67f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmd/snap/cmd_advise.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func init() {
// TRANSLATORS: This should not start with a lowercase letter.
"command": i18n.G("Advise on snaps that provide the given command"),
// TRANSLATORS: This should not start with a lowercase letter.
"from-apt": i18n.G("Advise will talk to apt via an apt hook"),
"from-apt": i18n.G("Run as an apt hook"),
// TRANSLATORS: This should not start with a lowercase letter.
"format": i18n.G("Use the given output format"),
}, []argDesc{
Expand Down
6 changes: 1 addition & 5 deletions cmd/snap/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ func lintDesc(cmdName, optName, desc, origDesc string) {
// decode the first rune instead of converting all of desc into []rune
r, _ := utf8.DecodeRuneInString(desc)
// note IsLower != !IsUpper for runes with no upper/lower.
// Also note that login.u.c. is the only exception we're allowing for
// now, but the list of exceptions could grow -- if it does, we might
// want to change it to check for urlish things instead of just
// login.u.c.
if unicode.IsLower(r) && !strings.HasPrefix(desc, "login.ubuntu.com") {
if unicode.IsLower(r) && !strings.HasPrefix(desc, "login.ubuntu.com") && !strings.HasPrefix(desc, cmdName) {
noticef("description of %s's %q is lowercase: %q", cmdName, optName, desc)
}
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/snap/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,10 @@ func (s *SnapSuite) TestLintDesc(c *C) {
}
c.Check(fn, PanicMatches, `option on "command" has no name`)
log.Reset()

snap.LintDesc("snap-advise", "from-apt", "snap-advise will run as a hook", "")
c.Check(log.String(), HasLen, 0)
log.Reset()
}

func (s *SnapSuite) TestLintArg(c *C) {
Expand Down

0 comments on commit 8a2c67f

Please sign in to comment.