sfi can use partial non-ambiguous command names like sfaadmin
[sfa.git] / sfa / client / sfaadmin.py
index c1738cd..d676de6 100755 (executable)
@@ -12,6 +12,8 @@ from sfa.client.sfi import save_records_to_file
 from sfa.trust.hierarchy import Hierarchy
 from sfa.trust.gid import GID
 
+from sfa.client.candidates import Candidates
+
 pprinter = PrettyPrinter(indent=4)
 
 try:
@@ -28,21 +30,6 @@ def args(*args, **kwargs):
         return func
     return _decorator
 
-### utility to match command-line args to names
-class Candidates:
-    def __init__ (self, names):
-        self.names=names
-    # is an input string acceptable for one of the known names?
-    @staticmethod
-    def fits (input, name):
-        return name.find(input)==0
-    # returns one of the names if the input name has a unique match
-    # or None otherwise
-    def only_match (self, input):
-        matches=[ name for name in self.names if Candidates.fits(input,name) ]
-        if len(matches)==1: return matches[0]
-        else: return None
-
 class Commands(object):
     def _get_commands(self):
         command_names = []