Skip to content
This repository has been archived by the owner on Apr 19, 2022. It is now read-only.

Flag web-config-apps as string instead of string slice #28

Merged
merged 7 commits into from
Jan 16, 2020

Conversation

refs
Copy link
Member

@refs refs commented Jan 15, 2020

I rather parse a comma separated string values into a []string than fight StringSliceFlag. Documentation has been added.

For more information have a look at:

urfave/cli#392 (part of urfave/cli v2)
urfave/cli#160 (closed in v2, we're using v1)

@refs refs requested a review from butonic January 15, 2020 10:13
@butonic
Copy link
Member

butonic commented Jan 15, 2020

@refs where do you actually cut the apps into parts?

@refs
Copy link
Member Author

refs commented Jan 15, 2020

@butonic in the ocis PhoenixCommand. Here not just yet, as it is not used anywhere yet in this project.

@refs
Copy link
Member Author

refs commented Jan 15, 2020

this is being followed up by a PR on ocis where I actually make use of it. I'm however adding a helper to phoenix flagset to capture this behavior within this package, as it's not ocis concern to do it. this functionality was moved to owncloud/ocis-pkg

@tboerger
Copy link
Contributor

Codacy Here is an overview of what got changed by this pull request:

Complexity increasing per file
==============================
- pkg/command/server.go  1
         

See the complete overview on Codacy

@tboerger
Copy link
Contributor

That sounds odd, the default usage of string slice flags seems much more common to provide the flag multiple times instead of the comma separated list.

@refs
Copy link
Member Author

refs commented Jan 15, 2020

That sounds odd, the default usage of string slice flags seems much more common to provide the flag multiple times instead of the comma separated list.

🤷‍♂ I find repeating the web-config-apps more arduous than just a comma separated set of values. WDYT? Is this common?

@tboerger
Copy link
Contributor

which problem do you want to resolve that way? Only the missing Destination flag? I personally resolve that issue (until it gets fixed upstream) be assigning the string slice to the config struct within a Before handler.

@refs
Copy link
Member Author

refs commented Jan 15, 2020

StringSlice flags defaults are not overridden, as urfave/cli#160 specifies.

I cracked a small example:

package main

import (
	"fmt"
	"log"
	"os"

	"github.com/urfave/cli"
)

func main() {
	app := cli.NewApp()
	app.Name = "greet"
	app.Usage = "fight the loneliness!"
	app.Action = func(c *cli.Context) error {
		value := c.StringSlice("list")
		fmt.Println(value)

		return nil
	}
	app.Flags = []cli.Flag{
		cli.StringSliceFlag{
			Name:  "list",
			Value: &cli.StringSlice{"1", "2", "3"},
		},
	}

	err := app.Run(os.Args)
	if err != nil {
		log.Fatal(err)
	}
}

./urfave --list 4 --list 5 --list 6 // [1 2 3 4 5 6]

This is totally broken IMO, it doesn't override default values!

@tboerger
Copy link
Contributor

We could also assign the default if the slice is empty within Before, submit a PR to micro cli, and remove the Before workaround when we got it merged upstream. That way everybody using micro would benefit ;)

@tboerger
Copy link
Contributor

And that way AFAIK both fractions can be happy because if I remember correctly comma separated strings are transformed into the string slice automatically while others can use the expected behavior --list 4 --list 5 --list 6 :D

@refs
Copy link
Member Author

refs commented Jan 16, 2020

As messed around this morning this would mean a fix upstream (upstream being urfavecli) as it still presents this bug: urfave/cli#549 Until I (or someone else) contributes to urfavecli fixing it, then adding the fix into micro/cli, it might be a viable option to have our fix merged on our end, move on, and tag this to deal with it at its time.

@butonic butonic merged commit 8ce2f00 into master Jan 16, 2020
@delete-merged-branch delete-merged-branch bot deleted the feature/apps-as-cli-flag branch January 16, 2020 15:19
ownclouders pushed a commit that referenced this pull request Jan 16, 2020
Merge: 8b3ea40 761e114
Author: Jörn Friedrich Dreyer <jfd@butonic.de>
Date:   Thu Jan 16 16:19:03 2020 +0100

    Merge pull request #28 from owncloud/feature/apps-as-cli-flag

    Flag web-config-apps as string instead of string slice
@tboerger
Copy link
Contributor

Great, merging without talking about my complains...

@butonic
Copy link
Member

butonic commented Jan 16, 2020

I was told this was discussed in the office and ok to merge. 🤷‍♂️

I guess the question is how we keep track of the upstream bug? We are not reusing projects, so adding the external bug to the current sprint is possible but we would risk loosing track of it.

Edit: added as https://github.com/orgs/owncloud/projects/142#card-31751793

@butonic butonic added the enhancement New feature or request label Jan 16, 2020
@refs
Copy link
Member Author

refs commented Jan 17, 2020

It was my call; assumed things were clear when we discussed them at the office. I'll follow this up with a set of PR's on urfave / micro / owncloud. Hopefully it gets updated upstream.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants