Cosmos-sdk: Drop text output format in favor of JSON

Created on 18 May 2019  路  10Comments  路  Source: cosmos/cosmos-sdk

Indented JSON is a reasonably human readable format per se. We should default to it and drop the current text format as it would help simplify the code that handles output formatting and printing.

In my view, we should:

  • Drop the --output flag entirely (it comes from tendermint cli libs, we could just ignore it and just pass json down to tendermint)
  • Change the --indent flag to accept a numerical value through which users may adjust output indentation according to their preferences.

Indent could (should?) be set to zero to provide a compact, byte-saving machine parseable format. Users could adjust their preferences and set a custom indentation level globally via the gaiacli configuration file.

Please discuss @alexanderbez @jackzampolin @sabau @fedekunze @rigelrozanski


For Admin Use

  • [ ] Not duplicate issue
  • [ ] Appropriate labels applied
  • [ ] Appropriate contributors tagged
  • [ ] Contributor assigned/self-assigned
CLI discussion proposal-accepted

All 10 comments

I'm OK with only supporting JSON as output 馃憣

If we have an --indent flag, it should take numeric values as you suggested with the default being either 0 or 2.

Meh I think I've changed my opinion. Like there is no question that the tabular keys need to reformatted, but I think Human-Readable Output is really important for some of the other structs. So like; why not still have HRO for keys in _non-tabular_ format? I think that's the real solution here. I've got strong doubts on exclusively using JSON.

Other structs would be printed in a prettified, human friendly JSON anyway. IMHO the greatest benefits of adopting JSON would come from making all human format handling code redundant

still not convinced we should just be printing JSON. However I hear you on the want to have redundant output for text and json. My compromise would be to have a text base "pretty" formatter, that would have input of json, and output human readable, by changing spacing, and removing { brackets etc. . For example:

JSON:

{
  "name": "json.human",
  "description": "Convert\n JSON to human readable\r HTML",
  "author": "Mariano Guerra <[email protected]>",
  "tags": ["DOM", "HTML", "JSON", "Pretty Print"],
  "version": "0.1.0",
  "main": "json.human.js",
  "license" : "MIT",
  "dependencies": {
      "crel": "1.0.0"
  },
}

HRO:

  name: json.human
  description: Convert\n JSON to human readable\r HTML
  author: Mariano Guerra <[email protected]>
  tags: [DOM, HTML, JSON, Pretty Print]
  version: 0.1.0
  main: json.human.js
  license: MIT
  dependencies: 
      crel: 1.0.0

I think this kind of processing printer probably already exists, OR can simply be made quite easily by parsing the JSON itself. Honestly it looks like if we just search replace " ,\n``{, }, that is pretty much it already

@rigelrozanski what you're describing as HRO looks like YAML. Perhaps we should support JSON and YAML where YAML is the "text" HRO. This should be trivial to implement and really cuts down on custom code.

Yes! That's YAML. I'd second that!

Yup sweet

Awesome -- love the "synergy" 馃槅

EDIT: @alessio mind updating the issue body with "acceptance criteria" please?

@alessio why? text will just print/output YAML. I don't see a need to actually change Tendermint.

Was this page helpful?
0 / 5 - 0 ratings