Skip to content

Commit

Permalink
launch: add option to force update
Browse files Browse the repository at this point in the history
  • Loading branch information
fiws committed Jun 16, 2021
1 parent 1f9688c commit dc603c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions cmd/launch.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Alternatively: Can be used in directories containing a minepkg.toml manifest to
}, runner)

cmd.Flags().BoolVarP(&runner.serverMode, "server", "s", false, "Start a server instead of a client")
cmd.Flags().BoolVarP(&runner.forceUpdate, "update", "u", false, "Force check for updates before starting")
cmd.Flags().BoolVar(&runner.debugMode, "debug", false, "Do not start, just debug")
cmd.Flags().BoolVar(&runner.offlineMode, "offline", false, "Start the server in offline mode (server only)")
cmd.Flags().BoolVar(&runner.onlyPrepare, "only-prepare", false, "Only prepare, skip launching")
Expand All @@ -54,6 +55,7 @@ type launchRunner struct {
crashTest bool
noBuild bool
demo bool
forceUpdate bool

overwrites *launch.OverwriteFlags

Expand Down Expand Up @@ -114,6 +116,7 @@ func (l *launchRunner) RunE(cmd *cobra.Command, args []string) error {
Instance: l.instance,
ServerMode: l.serverMode,
OfflineMode: l.offlineMode,
ForceUpdate: l.forceUpdate,
MinepkgVersion: rootCmd.Version,
NonInteractive: viper.GetBool("nonInteractive"),
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/launch/prepare.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ type CLILauncher struct {
// OfflineMode indicates if this server should be started in offline mode
OfflineMode bool

// ForceUpdate will force a full dependency resolve if set to true
ForceUpdate bool

// LaunchManifest is a minecraft launcher manifest. it should be set after
// calling `Prepare`
LaunchManifest *minecraft.LaunchManifest
Expand Down Expand Up @@ -72,7 +75,7 @@ func (c *CLILauncher) Prepare() error {
}

fmt.Print(pipeText.Render(gchalk.BgGray("Requirements")))
if outdatedReqs {
if c.ForceUpdate || outdatedReqs {
fmt.Print(gchalk.Gray("(updating)"))
err := instance.UpdateLockfileRequirements(context.TODO())
if err != nil {
Expand Down Expand Up @@ -100,7 +103,7 @@ func (c *CLILauncher) Prepare() error {

// also update deps when reqs are outdated
fmt.Print(pipeText.Render(gchalk.BgGray("Dependencies")))
if outdatedReqs || outdatedDeps {
if c.ForceUpdate || outdatedReqs || outdatedDeps {
fmt.Print(gchalk.Gray("(updating)\n"))
if err := c.newFetchDependencies(ctx); err != nil {
return err
Expand Down

0 comments on commit dc603c0

Please sign in to comment.