mission-control-indexer icon indicating copy to clipboard operation
mission-control-indexer copied to clipboard

indexercli has control / escaped charachters in output

Open koen84 opened this issue 4 years ago • 2 comments

If you run :

graph indexer rules get all --output yaml > test.yaml
graph indexer rules get all --output json > test.json

it'll have invisible characters in the output, which is a problem to process with other tools.

YAML :

^[[0m- deployment: global^[[0m
^[[0m  allocationAmount: "0.01"^[[0m
^[[0m  parallelAllocations: "2"^[[0m
^[[0m  maxAllocationPercentage: null^[[0m
^[[0m  minSignal: null^[[0m
^[[0m  maxSignal: null^[[0m
^[[0m  minStake: null^[[0m
^[[0m  minAverageQueryFees: null^[[0m
^[[0m  custom: null^[[0m
^[[0m  decisionBasis: never^[[0m

JSON :

^[[0m[^[[0m
^[[0m  {^[[0m
^[[0m    "deployment": "global",^[[0m
^[[0m    "allocationAmount": "0.01",^[[0m
^[[0m    "parallelAllocations": "2",^[[0m
^[[0m    "maxAllocationPercentage": null,^[[0m
^[[0m    "minSignal": null,^[[0m
^[[0m    "maxSignal": null,^[[0m
^[[0m    "minStake": null,^[[0m
^[[0m    "minAverageQueryFees": null,^[[0m
^[[0m    "custom": null,^[[0m
^[[0m    "decisionBasis": "never"^[[0m
^[[0m  }^[[0m
^[[0m]^[[0m

koen84 avatar Nov 12 '20 10:11 koen84

This is because the cli apparently outputs a colored scheme and pipes can't handle them by default. If you want to escape the characters do this, for example: graph indexer rules get all --output json | sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g" > test.json

More information here: https://stackoverflow.com/questions/17998978/removing-colors-from-output

trader-payne avatar Nov 13 '20 23:11 trader-payne

For me it worked with just this |sed 's/\x1b\[[0-9;]*m//g' At least that way anything not belonging wasn't anymore in the resulting file. This makes jq happy too. graph indexer rules get all --merged --output json |sed 's/\x1b\[[0-9;]*m//g' | jq

koen84 avatar Nov 14 '20 00:11 koen84