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

Fix issue #6511 - CLI listing formatting ignored when passing --search #6531

Closed
wants to merge 1 commit into from

Conversation

pablodelarco
Copy link
Contributor

This pull request addresses issue #6511, which concerns the CLI listing formatting being ignored when the --search option is used with the onevm list command.

The problem was pinpointed to a section of the onevm command located in src/cli. The issue occurred in the command definition block for :list, where the conditional logic did not account for --json and --yaml formatting options when the --search flag was used. Specifically, the block that needed modification was as follows:

command :list, list_desc, [:filterflag, nil],
        :options => CLIHelper::OPTIONS + OpenNebulaHelper::OPTIONS +
                    [OpenNebulaHelper::DESCRIBE] + [OneVMHelper::SEARCH] do
    # ...existing code...
    if options[:xml]
        puts pool.to_xml
    else
        table.show(pool.to_hash, options)
    end
    # ...
end

I introduced conditional branches to handle the --json and --yaml options:

if options[:xml]
    puts pool.to_xml
elsif options[:json]
    puts JSON.pretty_generate(pool.to_hash)
elsif options[:yaml]
    puts pool.to_hash.to_yaml

With these additions, the onevm list command now respects the --json and --yaml flags in conjunction with the --search flag, providing output in the expected format.

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

Successfully merging this pull request may close these issues.

1 participant