New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add --list flag to open command #129
Conversation
pkg/cmd/open.go
Outdated
} | ||
|
||
func init() { | ||
openCmd.Flags().Bool("list", false, "List available project's URLs") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the wrong option type
662017f
to
e41530a
Compare
pkg/helpers/open/open.go
Outdated
@@ -51,3 +51,10 @@ func FindLink(proj *project.Project, linkName string) (url string, err error) { | |||
|
|||
return | |||
} | |||
|
|||
func PrintLinks(proj *project.Project) { | |||
var url, title string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we get rid of this declaration?
pkg/helpers/open/open.go
Outdated
func PrintLinks(proj *project.Project) { | ||
var url, title string | ||
for title, url = range proj.Manifest.Open { | ||
fmt.Println(title, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better formatting ?
pkg/cmd/open.go
Outdated
@@ -1,17 +1,23 @@ | |||
package cmd | |||
|
|||
import ( | |||
"os" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0ae2926
to
aceb775
Compare
if GetFlagBool(cmd, "list") { | ||
err = open.PrintLinks(proj) | ||
checkError(err) | ||
os.Exit(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checkError
already exits with 1
(which may not be optimal in this case, but we can live with that I think)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there is no error though, we need to exit properly. Otherwise, we'll fail on the next error Error: which link should I open?
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the noise... 🤦♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no worries!
pkg/helpers/open/open.go
Outdated
} | ||
var url, title string | ||
for title, url = range proj.Manifest.Open { | ||
fmt.Println(title, url) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could use \t
as a limited attempt to align the columns.
28633e2
to
3c947af
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️
} | ||
|
||
return nil | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is not really in the scope of the open
helper.
It's fine to keep it here for now, but the fuzzy search adds some more code related to links, I think we should create a links
helper for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. Knowing how to print a link is not really the concern of the open
helper.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incremental changes! Let's ship that and keep it in mind!
3c947af
to
17516e3
Compare
17516e3
to
8774738
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯
Why
Add the
--list
flag support for the open command.The
--list
command modifier lists in the standard output the entries found in theopen
section ofdev.yml
configuration file.Resolves #111
How
Using Cobra local Flags primitive.