-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Create a v1 => v2 migration guide #921
Comments
Here's a PR where @ffrank and @purpleidea make the |
Here's a quirky example of someone moving from the very very old ☝️ I don't think that's the type of migration where's really looking to write documentation for? but it's interesting to look at |
v1
=> v2
migration guide
Here's another example migration PR google/cloud-print-connector#470 |
I'm going to work on this as a part of #952 |
In addition to working on this as a part of #952, I've been progressively updating the v2 release notes => https://github.com/urfave/cli/releases/tag/v2.0.0 to include fine grain migration instructions. I'll add more as I find them! |
#952 was closed, so I no longer intend on working on this |
+1 migration PR => technosophos/dashing#52 |
command line flag migration steps also need to be updated, at the very least to document the way command-line flag aliases now behave. Previously you could define aliases liek:
however you now need to do
Here is a minimal repro package main
import (
"fmt"
"os"
// auto register pprof handlers
_ "net/http/pprof"
au "github.com/logrusorgru/aurora"
"github.com/urfave/cli/v2"
)
func main() {
// generate the actual cli app
app := newApp()
// runthe cli app
if err := app.Run(os.Args); err != nil {
fmt.Printf(
"%s %s\n",
au.Bold(au.Red("error encountered:")),
au.Red(err.Error()),
)
os.Exit(1)
}
}
func newApp() *cli.App {
app := cli.NewApp()
app.Flags = loadFlags()
return app
}
func loadFlags() []cli.Flag {
return []cli.Flag{
&cli.BoolFlag{
Name: "bootstrap, bp",
Usage: "bootstrap against public ipfs",
},
&cli.StringFlag{
Name: "config, cfg",
Usage: "load the configuration file at `PATH`",
Value: "./config.yml",
},
}
} |
@bonedaddy 👍 I added these lines
|
sweet, thank you 🚀 |
I kept notes as I did a recent conversion. I think these are going to be the typical "first steps" for people (well... people like me!)
Change (Steal the examples in
What this means to you: a. Look for Example:
Compiler messages you might see:
b. If you are building a list of commands, change to pointers
Compiler messages you might see:
What this means to you: If you make a list of flags, add a
Compiler messages you might see:
b. appending to a list of commands needs pointers:
Compiler messages you might see:
Compiler messages you might see: ` |
Those are good notes, thanks @TomOnTime ✨ |
Thanks! If I may be so bold: I think the typical user of urfave/cli would rather have a few conversion tips now than the perfect document in the future. I would be honored if you published my notes as the starting point; people could send PRs with improvements over time. It turns out that the conversion process is pretty easy, but I had been avoiding it because I didn't know how hard or difficult it would be. Luckily I had some free time this weekend and decided to guess my way through the compiler errors and see if it would "just work". Other people might not be so willing to "just try it". A nudge in the docs would empower people to give it a try. |
I'll follow up on this sometime soon 👍 |
I'm not sure if this is intentional, a side effect or something I have done wrong but after moving from v1 to v2, flags must come before args ie: This will work
This will not
If this is intentional i couldn't find it documented anywhere and is a major gotcha for migrating. |
I took a swing at this. See #1098 |
@nodefortytwo that change isn't specific to V2, it's an issue where the behavior flipped back and forth in V1 too. Here's an example of me changing some V1 code for this problem => #872 |
@nodefortytwo if you have capacity, I would welcome contributors for more test cases here! It's never been 100% clear what the ideal behavior should be, which is why the behavior has shifted over time. |
In cli.StringFlag type, |
@guo1017138 ... please take a look at #1137 |
Another change to document - |
|
View the release notes for guidance on migrating => https://github.com/urfave/cli/releases/tag/v2.0.0
The text was updated successfully, but these errors were encountered: