birdayz / kaf

Modern CLI for Apache Kafka, written in Go.
Apache License 2.0
2.21k stars 142 forks source link

json/yaml support #6

Open birdayz opened 6 years ago

birdayz commented 6 years ago

Support automated use of this tool.

knadh commented 5 months ago

Hi @birdayz. Thank you for writing kaf!

Would you be open to a PR that adds an --output=json flag (or whatever name) that returns JSON output?

Example:

$> kaf topic describe test

Name:        test    
Internal:    false   
Compacted:   false   
Partitions:
  Partition  High Watermark  Leader  Replicas  ISR  
  ---------  --------------  ------  --------  ---  
  0          11              1       [1]       [1]  
Summed HighWatermark:  11
Config:
  Name               Value      ReadOnly  Sensitive  
  ----               -----      --------  ---------  
  retention.ms       10000000   false     false      
  max.message.bytes  100000000  false     false  
$> kaf --output=json topic describe test 
{
  "name": "test",
  "internal": false,
  "compacted": false,
  "partitions": [
    {
      "partition": 0,
      "highwatermark": 11,
      "leader": 1,
      "replicas": [1],
      "isr": [1]
    }
  ],
  "summed_high_watermark": 11,
  "config": [
    {
      "name": "retention.ms",
      "value": "10000000",
      "readonly": false,
      "sensitive": false
    },
    {
      "name": "max.message.bytes",
      "value": "100000000",
      "readonly": false,
      "sensitive": false
    }
  ]
}