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

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

Open
EnigmaTriton opened this issue May 15, 2016 · 2 comments
Open

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

EnigmaTriton opened this issue May 15, 2016 · 2 comments

Comments

@EnigmaTriton
Copy link

EnigmaTriton commented May 15, 2016

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.

@MestreLion
Copy link
Owner

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?

@EnigmaTriton
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants