bbende / nifi

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

UX: add support for positional backreferences in interactive mode #42

Closed aperepel closed 6 years ago

aperepel commented 6 years ago

Here's an idea I prototyped and wanted some feedback. It applies only to an interactive mode.

As a user, I want to cut down on the amount of UUID copy/pasting I need to do when navigating the registry tree and supplying mandatory id params to commands. Let me use a special reference syntax to 'grab that row' which I just listed, supplying just its positional argument.

Here's how a sample session looks like (note the &4 positional reference in the second command):

#> 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     QuickImport        4d18d86e-b204-4bc0-b419-2e1818156849   (empty)                                 
4     Second Bucket      76dbb3e8-a812-4bb2-800a-ba3a4ec3ed72   (empty)                                 

#> registry list-flows -b &2

Using a positional backreference for 'DCH'

#     Name         Id                                     Description                             
---   ----------   ------------------------------------   ----------------------------------------
1     Dan's flow   e690f578-b02a-4cea-b88f-c77cbbfb7286   (empty)                                 
2     SFTP Flow    0992fd2f-614d-4d4d-b8c3-9f7fafe30fc2                                           

#> registry list-flow-versions -f &2                                                                            

Using a positional backreference for 'SFTP Flow'

Ver   Date                         Author      Message                                 
---   --------------------------   ---------   ----------------------------------------
  1   Sun, Feb 11 2018 12:11 EST   anonymous                                           
  2   Sun, Feb 11 2018 12:13 EST   anonymous   Color changes                           
  3   Sun, Feb 11 2018 13:09 EST   anonymous   Color changes                           

#>

Implementation notes

Added a map in the context object which is cleared and populated every time one performs some list-XXX command and maintains the same ordering as the one on-screen. If a user tries to list A, then list B, and backref &A1, the results are non-deterministic, and we are not targeting this robustness level. The only goal is to cut down on the keyboard and mouse fatigue and raise productivity.