humblebundle icon indicating copy to clipboard operation
humblebundle copied to clipboard

The --list-bundles/-L option does not handle --json/-j option

Open EnigmaTriton opened this issue 8 years ago • 2 comments

When asking for the list of bought bundles, we always get the flat list even if --json option is passed.

Since the normal dump would be pretty big, I tried to produce a simpler output (maybe not the cleanest possible but it might proves useful to some besides me).

Here is the added code from line 779 (GitHub does not accept the patch file and I don't want to bother with a fork & pull-request):

elif args.list_bundles:
    bundles = hb.bundles.items()
    if args.json:
        print ('[')
        for bundle in sorted(bundles):
            print ('  [')
            print ('    "%s",' % bundle[1]['machine_name'])
            print ('    {')
            print ('      "machine_name": "%s"' % bundle[1]['machine_name'])
            print ('      "human_name": "%s"' % bundle[1]['human_name']).encode('utf-8')
            print ('    }')
            print ('  ],')
        print (']')
        return
    for bundle in sorted(bundles):

Hope it will help.

EnigmaTriton avatar May 15 '16 20:05 EnigmaTriton

Thanks, that's a nice suggestion!

And by the way, --json also does not work with --list

Maybe an even simpler format is better? I'm thinking about this:

[
    ["machine_name_A", "human_name_A"],
    ["machine_name_B", "human_name_B"],
   ...
]

What do you think?

MestreLion avatar Aug 24 '16 03:08 MestreLion

Seems reasonable enough. In fact, I choose the slightly more complex format only to be a subset of the full version but when we call with these options, we obviously search for a simple answer so it makes perfect sense.

EnigmaTriton avatar Aug 25 '16 17:08 EnigmaTriton