-
-
Notifications
You must be signed in to change notification settings - Fork 39
Add JSON output capabilities #21
base: master
Are you sure you want to change the base?
Conversation
@@ -50,6 +53,7 @@ Options: | |||
--charset CHARSET Set the character set to use in output. Valid | |||
values: utf8, ascii [default: utf8] | |||
-f, --format FORMAT Format string for printing dependencies | |||
-j, --json Print a JSON representation of the tree |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd make sense to match the --output-format
flag that Cargo uses, and make the JSON representation compatible with that.
@@ -317,6 +330,13 @@ struct Graph<'a> { | |||
nodes: HashMap<&'a PackageId, NodeIndex>, | |||
} | |||
|
|||
#[derive(Debug, Serialize, Deserialize)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to implement Deserialize I don't think.
@@ -214,6 +219,14 @@ fn real_main(flags: Flags, config: &Config) -> CliResult { | |||
flags.flag_all); | |||
println!(""); | |||
} | |||
} else if flags.flag_json { | |||
println!("{}", serde_json::to_string_pretty( | |||
&graph_to_tree(package.package_id(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems a bit strange that this mode would ignore a bunch of the flags the other modes respect.
Have you taken a look at |
Unfortunately |
What do you mean by resolved features? I would kind of like to keep this project focused on user-facing output. |
I needed this to be able to output JSON for parsing elsewhere.