bbende / nifi

Mirror of Apache NiFi
Apache License 2.0
1 stars 1 forks source link

Implemented nice dynamic table output for all list-XXX commands (in simple mode) #35

Closed aperepel closed 6 years ago

aperepel commented 6 years ago

Sample session:

#> nifi list-reg-clients                                                                                        

#     Name             Id                                     Uri                   
---   --------------   ------------------------------------   ----------------------
  1   Local Registry   5c24947c-0161-1000-e7b0-031c5a1197eb   http://localhost:18080

#> registry list-buckets                                                                                        

#     Name               Id                                     Description                             
---   ----------------   ------------------------------------   ----------------------------------------
1     API First Bucket   42c47c13-5694-4b77-88c6-ef48d4b9dbc1   (empty)                                 
2     DCH                078cbb53-afa4-437a-ad5a-83665b3459dd   (empty)                                 
3     Second Bucket      76dbb3e8-a812-4bb2-800a-ba3a4ec3ed72   (empty)                                 

#> registry list-flows -b 76dbb3e8-a812-4bb2-800a-ba3a4ec3ed72                                                  

#     Name               Id                                     Description                             
---   ----------------   ------------------------------------   ----------------------------------------
1     Imported via API   29d9aab4-3c46-43d7-a70e-1d1a876166ac   (empty)                                 

#> registry list-flow-versions -f 29d9aab4-3c46-43d7-a70e-1d1a876166ac                                          

Ver   Date                         Author      Message                                         
---   --------------------------   ---------   ------------------------------------------------
  1   Sat, Feb 03 2018 10:08 EST   anonymous                                                   
  2   Sat, Feb 03 2018 16:25 EST   anonymous   Added a property referencing a variable registry
  3   Sat, Feb 10 2018 15:51 EST   anonymous   Added a property referencing a variable registry
  4   Sat, Feb 10 2018 16:13 EST   anonymous   Added a property referencing a variable registry
  5   Sat, Feb 10 2018 16:15 EST   anonymous   Added a property referencing a variable registry
  6   Sat, Feb 10 2018 16:24 EST   anonymous   Added a property referencing a variable registry
  7   Sat, Feb 10 2018 16:25 EST   anonymous   Added a property referencing a variable registry

#>                                                                              
aperepel commented 6 years ago

I haven't modified the interface API to provide fewer disruptions, but most of the single-item writeXXX methods can now be removed.

bbende commented 6 years ago

@aperepel I like the improved layout, thanks for working on this. Two questions/comments...

1) Given that bucket and flow names can be 200 chars, and description and commit comments can be 4k chars, I think we should be doing something to only show some maximum number of chars for those fields. I think it'd be better to see the beginning of a name or description and then cut it off with an ellipse, rather than a messed up layout.

2) Originally I was envisioning someone writing shell scripts that composed several calls to the CLI in stand-alone mode in order to automate some task. Do you think this layout makes it any harder to parse the simple output using common bash utilities like sed/awk in order to feed a result back into the next command? I guess the json output is always an option, although I'm not familiar with handling json from a shell script.

aperepel commented 6 years ago

@bbende

  1. I'm all for truncating with ellipsis, just didn't want to bring in https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringUtils.html#abbreviate-java.lang.String-int- yet. Maybe copy? I kinda expect comments to be long, thus made it the last column, but with name potentially long, let's bring in this abbreviation code with ellipsis. I could take a look after we apply the PR, there are some non-obvious tricks going on in streaming code.
  2. I thought about automation with bash, but realized that we want the commands to be super simple and intuitive, like 'quick-import'. It will be very difficult parsing and acting on all possible outcomes and failures. So, IMO, we have json output for that and e.g. provide higher-level macro commands for common tasks.