Roundup Tracker - Issues

Issue 2551326

add completer function for roundup-admin when using readline
Type: rfe Severity: minor
Components: Command-line interface Versions:
Status: new
: : rouilj
Priority: :

Created on 2024-03-10 16:27 by rouilj, last changed 2024-03-13 22:29 by rouilj.

msg7960 Author: [hidden] (rouilj) Date: 2024-03-10 16:27
GNU readline can do tab completion. It would be nice to have this added to roundup-admin.

Completion can include:

  command name
  any classname parameter including the classname part of a designator
  class properties when a command specifies a class. E.G. complete 'ti' -> 'title='
          for 'create issue ti'
  'pragma' setting name
  directory/file paths: tracker home directory, export/import directories,
      genconfig/updateconfig filenames
  'restore' possibly list only retired designators?
  'security' complete role names

  'get' is a weird command. It take property first then designators. So tab completion
    on property is probably not helpful as we can't narrow it to completing within a class.

For example:

set <tab complete classes><no tab complete id> <tab complete properties>=<no tab complete>
msg7961 Author: [hidden] (rouilj) Date: 2024-03-10 17:40
Since readline doc is sparse, Examples:

also look at the rl package:

readline as provided in the standard library is missing some things. E.g. you can set
variables for use in the init file. rl claims to have extended api access to better
match the full GNU readline api.
msg7962 Author: [hidden] (rouilj) Date: 2024-03-13 22:29
More reference:

with example:

import readline

def make_completer(vocabulary):
    def custom_complete(text, state):
        # None is returned for the end of the completion session.
        results = [x for x in vocabulary if x.startswith(text)] + [None]
        # A space is added to the completion since the Python readline doesn't
        # do this on its own. When a word is fully completed we want to mimic
        # the default readline library behavior of adding a space after it.
        return results[state] + " "
    return custom_complete

def main():
    vocabulary = {'cat', 'dog', 'canary', 'cow', 'hamster'}
    readline.parse_and_bind('tab: complete')

        while True:
            s = input('>> ').strip()
    except (EOFError, KeyboardInterrupt) as e:
        print('\nShutting down...')

if __name__ == '__main__':
Date User Action Args
2024-03-13 22:29:24rouiljsetmessages: + msg7962
2024-03-10 17:40:52rouiljsetmessages: + msg7961
2024-03-10 16:27:02rouiljcreate