| 184 | display = "path" |
| 185 | |
| 186 | def completion( |
| 187 | self, manager: "CommandManager", t: type, start: str |
| 188 | ) -> Sequence[str]: |
| 189 | if not start: |
| 190 | start = "./" |
| 191 | path = os.path.expanduser(start) |
| 192 | ret = [] |
| 193 | if os.path.isdir(path): |
| 194 | files = glob.glob(os.path.join(path, "*")) |
| 195 | prefix = start |
| 196 | else: |
| 197 | files = glob.glob(path + "*") |
| 198 | prefix = os.path.dirname(start) |
| 199 | prefix = prefix or "./" |
| 200 | for f in files: |
| 201 | display = os.path.join(prefix, os.path.normpath(os.path.basename(f))) |
| 202 | if os.path.isdir(f): |
| 203 | display += "/" |
| 204 | ret.append(display) |
| 205 | if not ret: |
| 206 | ret = [start] |
| 207 | ret.sort() |
| 208 | return ret |
| 209 | |
| 210 | def parse(self, manager: "CommandManager", t: type, s: str) -> str: |
| 211 | return os.path.expanduser(s) |