Skip to content
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

Port cmd/fyne to using urfave/cli #1858

Merged
merged 17 commits into from
Feb 6, 2021
Merged

Port cmd/fyne to using urfave/cli #1858

merged 17 commits into from
Feb 6, 2021

Conversation

Jacalz
Copy link
Member

@Jacalz Jacalz commented Jan 24, 2021

Description:

This PR moves ahead with the task of porting over the entire cmd/fyne cli application to using https://github.com/urfave/cli. It currently needs more testing and I would like if people take a look at my proposed flag aliases and names along with any usages or descriptions that need to be updated with better wording. Of note is that the cmd/fyne/commands package has a couple breakages, but it should only affect the commands themselves (I don't think the intention ever was to let other people create cli applications with it).

The work on porting to cobra was abandoned due to the fact that flags had to be posix compliant.
Supersedes #1312

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style.
  • Any breaking changes have a deprecation path or have been discussed.

@Jacalz Jacalz changed the title Urfave cli Port cmd/fyne to using urfave/cli Jan 24, 2021
@AlbinoGeek
Copy link
Contributor

AlbinoGeek commented Jan 25, 2021

I really don't like single dash command arguments -key=val that Golang does, they specifically chose not to listen to the standardized way of doing things, with no discernible benefit whatsoever (except typing one less dash? but arguments are auto-completed by any shell written in the last 10 years... so who cares?)

In fact, it makes single dash arguments "not chainable", which is pretty dumb. (see: any *nix command ever: cmd -ancRQ)

Which brings me to the point of that rant:

  • Does urfive support auto-complete? fyne r<tab>elease etc
  • Does urfive support levenshtein distance-based auto-correction? fyne rlesae -> fyne release

Those were the only real real features that cobra provided over any other cli impl. (Well, that and viper integration.)


Alright, review done, I'm sorry, haha.

cmd/fyne/commands/deprecated.go Outdated Show resolved Hide resolved
cmd/fyne/commands/deprecated.go Outdated Show resolved Hide resolved
cmd/fyne/commands/get.go Outdated Show resolved Hide resolved
cmd/fyne/commands/get.go Outdated Show resolved Hide resolved
cmd/fyne/commands/install.go Outdated Show resolved Hide resolved
&cli.StringFlag{
Name: "target",
Aliases: []string{"os"},
Usage: "The operating system to target (android, android/arm, android/arm64, android/amd64, android/386, darwin, freebsd, ios, linux, netbsd, openbsd, windows)",
Copy link
Contributor

Choose a reason for hiding this comment

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

What is android v.s android/386 ? Is that practically android/arm386?

Also, where did 32-bit BSD, Linux and Windows go?

Copy link
Member Author

Choose a reason for hiding this comment

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

We probably shouldn't list all of possible values in the usage. The list we have is way too long.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense. If extended helps comes up somewhere, we could link an FAQ or developer.fyne page that has information on building, or lists architectures.

cmd/fyne/commands/release.go Outdated Show resolved Hide resolved
cmd/fyne/main.go Show resolved Hide resolved
cmd/fyne/main.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
@andydotxyz
Copy link
Member

Is there any way we can test that this change is backward compatible?
I like the idea, as discussed on the call, but it's important that the changes are all aliased/deprecated to not break any usage.

Copy link
Contributor

@AlbinoGeek AlbinoGeek left a comment

Choose a reason for hiding this comment

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

Love what I'm seeing :) New changes look great.

Also good to know I'm now the only one using spew.Dump() to debug :P

cmd/fyne/commands/deprecated.go Outdated Show resolved Hide resolved
@Jacalz
Copy link
Member Author

Jacalz commented Jan 30, 2021

Love what I'm seeing :) New changes look great.

Also good to know I'm now the only one using spew.Dump() to debug :P

Thanks. I don't use spew.Dump(). Where did you get that from?

@Jacalz Jacalz marked this pull request as ready for review January 30, 2021 18:10
@AlbinoGeek
Copy link
Contributor

AlbinoGeek commented Jan 30, 2021

Love what I'm seeing :) New changes look great.
Also good to know I'm now the only one using spew.Dump() to debug :P

Thanks. I don't use spew.Dump(). Where did you get that from?

I got that from the go.sum removal of a lingering import of github.com/davecgh/go-spew.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

I think a few changes like re-ordering and doc removal need to be reversed.

The main problem here is that we have a new public API that is exposing 3rd party CLI interface types instead of our own. This is something we try to avoid, the solution may need some more thinking.

cmd/fyne/commands/bundle.go Show resolved Hide resolved
cmd/fyne/commands/bundle.go Show resolved Hide resolved
cmd/fyne/commands/bundle.go Outdated Show resolved Hide resolved
cmd/fyne/commands/bundle.go Outdated Show resolved Hide resolved
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Overall this is looking good - sorry it has been so much work!

There is a problem - as far as I can see NewGetter has been removed from the public API.
The struct is there, but not the constructor or methods.

cmd/fyne/internal/commands/deprecated.go Outdated Show resolved Hide resolved
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

So close.

However when I try to use this the Get(string) and SetIcon(string) methods are not found on Getter. We may need public definitions that wrap...

Or you could use type Getter = commands.Getter to expose all of the internally-public methods.

andydotxyz
andydotxyz previously approved these changes Feb 6, 2021
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Looks good to me. Might be good to get another 👍 if possible, but it won't block merging.

go.sum Outdated Show resolved Hide resolved
AlbinoGeek
AlbinoGeek previously approved these changes Feb 6, 2021
Copy link
Contributor

@AlbinoGeek AlbinoGeek left a comment

Choose a reason for hiding this comment

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

Looks like everything I'd commented on has been addressed.

@Jacalz
Copy link
Member Author

Jacalz commented Feb 6, 2021

Sorry for the force push. Had to rebase on develop and git wouldn't let me push normally.

Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

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

Looks like a random code addition snuck into cmd/hello/main.go

cmd/hello/main.go Outdated Show resolved Hide resolved
@Jacalz Jacalz merged commit 75ddc86 into fyne-io:develop Feb 6, 2021
@Jacalz Jacalz deleted the urfave-cli branch February 6, 2021 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants