Crates.io | aidl-cli |
lib.rs | aidl-cli |
version | 0.2.0 |
source | src |
created_at | 2022-01-10 20:16:55.605749 |
updated_at | 2022-01-10 20:16:55.605749 |
description | Simple AIDL command line tool |
homepage | |
repository | https://github.com/bwalter/aidl-cli |
max_upload_size | |
id | 511617 |
size | 42,726 |
Command line to to parse AIDL files and extract informations.
For language-specific features, see rust-aidl-parser.
USAGE:
aidl-cli [FLAGS] [OPTIONS] <dir>
FLAGS:
-i, --items Display items
-h, --help Prints help information
-q, --hide-diagnostics Do not show diagnostics
--pretty Make pretty (but longer) output
-j, --to-json Convert the whole AST to JSON
-y, --to-yaml Convert the whole AST to YAML
-V, --version Prints version information
OPTIONS:
-o, --output-path <output-path> Output file
ARGS:
<dir> The directory where the AIDL files are located
Display diagnostics only:
> aidl-cli /path/to/project
List items and files:
> aidl-cli -i /path/to/project
JSON Structure:
{
"root": <path_to_root_dir>,
"items": {
<item_name>: {
"path": <relative_path_to_item.aidl>,
"itemType": <interface|parcelable|enum>,
"elements": {
<element_name>: {
"elementType": <method|const|field|enumElement>,
"name": <element_name>,
... (element-specific info, e.g. field type, method args, ...) ...
},
...
}
},
...
}
}
Example:
> aidl-cli --to-json ~/path/to/aidl/project --pretty > test.json
/path/to/aidl/project/test/pkg/TestInterface.aidl (input):
package test.pkg;
import test.pkg.TestParcelable;
interface TestInterface {
const int VERSION = 12;
/**
* Say hello
*/
String hello(boolean loud, in TestParcelable data);
}
/path/to/aidl/project/test/pkg/TestParcelable.aidl (input):
package test.pkg;
parcelable TestParcelable {
/**
* The first field
*/
Array<String> field1;
/**
* The second field
*/
int field2;
}
test.json (output):
{
"root": "/path/to/aidl/project",
"items": {
"test.pkg.TestInterface": {
"path": "test/pkg/TestInterface.aidl",
"itemType": "interface",
"name": "TestInterface",
"elements": {
"hello": {
"elementType": "method",
"oneway": false,
"name": "hello",
"returnType": "String",
"args": [
{
"name": "loud",
"type": "boolean"
},
{
"name": "data",
"direction": "in",
"type": "test.pkg.TestParcelable"
}
],
"doc": "Say hello"
},
"VERSION": {
"elementType": "const",
"name": "VERSION",
"type": "int",
"value": 12,
}
}
},
"test.pkg.TestParcelable": {
"path": "test/pkg/TestParcelable.aidl",
"itemType": "parcelable",
"name": "TestParcelable",
"elements": {
"field1": {
"elementType": "field",
"name": "field1",
"type": "Array<String>",
"doc": "The first field"
},
"field2": {
"elementType": "field",
"name": "field2",
"type": "int",
"doc": "The second field"
}
}
}
}
}
Display all item names (requires jq):
> aidl-cli -j /path/to/project | jq '.items[] | .name'
Display all items as [{ <itemType>: <name>, elements: [<name>] }]
:
> aidl-cli -j /path/to/project | jq '.items[] | { (.itemType): .name, elements: [.elements[] | .name] }
Filter items by name (using regex) and display them as <itemType> <name>
:
> aidl-cli -j /path/to/project | jq '.items[] | select(.name | test("^I")) | "\(.itemType) \(.name)"'
Show the diff between projects (requires jd):
> aidl-cli -j /path/to/project1 > project1.json
> aidl-cli -j /path/to/project2 > project2.json
> jd project1.json project2.json
Example:
> aidl-cli --to-yaml ~/path/to/aidl/project