(self, rest='')
| 167 | return "<alias {} for {!r}>".format(self.name, self.cmd) |
| 168 | |
| 169 | def __call__(self, rest=''): |
| 170 | cmd = self.cmd |
| 171 | nargs = self.nargs |
| 172 | # Expand the %l special to be the user's input line |
| 173 | if cmd.find('%l') >= 0: |
| 174 | cmd = cmd.replace('%l', rest) |
| 175 | rest = '' |
| 176 | |
| 177 | if nargs==0: |
| 178 | if cmd.find('%%s') >= 1: |
| 179 | cmd = cmd.replace('%%s', '%s') |
| 180 | # Simple, argument-less aliases |
| 181 | cmd = '%s %s' % (cmd, rest) |
| 182 | else: |
| 183 | # Handle aliases with positional arguments |
| 184 | args = rest.split(None, nargs) |
| 185 | if len(args) < nargs: |
| 186 | raise UsageError('Alias <%s> requires %s arguments, %s given.' % |
| 187 | (self.name, nargs, len(args))) |
| 188 | cmd = '%s %s' % (cmd % tuple(args[:nargs]),' '.join(args[nargs:])) |
| 189 | |
| 190 | self.shell.system(cmd) |
| 191 | |
| 192 | #----------------------------------------------------------------------------- |
| 193 | # Main AliasManager class |
nothing calls this directly
no test coverage detected