Skip to content

Commit

Permalink
Renamed variable
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed Jun 25, 2024
1 parent 4be5458 commit 2ec17d3
Showing 1 changed file with 17 additions and 21 deletions.
38 changes: 17 additions & 21 deletions smbclientng/core/CommandCompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,12 +375,9 @@ def complete(self, text, state):
for sharename in shares.keys():
if sharename.lower().startswith(remainder.lower()):
matching_entries.append(shares[sharename]["name"])

# Add quoting for shlex
matching_entries = [shlex.quote(s) for s in matching_entries]

# Final matches
self.matches += [command + " " + m for m in matching_entries]
for m in matching_entries:
self.matches.append(command + " " + shlex.quote(m))

# Autocomplete directory
if "remote_directory" in self.commands[command]["autocomplete"]:
Expand All @@ -400,9 +397,9 @@ def complete(self, text, state):
else:
matching_entries.append(entry.get_longname() + '/')
#
for s in matching_entries:
if s.lower().startswith(remainder.lower()) or shlex.quote(s).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(s))
for m in matching_entries:
if m.lower().startswith(remainder.lower()) or shlex.quote(m).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(m))

# Autocomplete file
if "remote_file" in self.commands[command]["autocomplete"]:
Expand All @@ -422,9 +419,9 @@ def complete(self, text, state):
else:
matching_entries.append(entry.get_longname())
#
for s in matching_entries:
if s.lower().startswith(remainder.lower()) or shlex.quote(s).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(s))
for m in matching_entries:
if m.lower().startswith(remainder.lower()) or shlex.quote(m).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(m))

# Autocomplete local_directory
if "local_directory" in self.commands[command]["autocomplete"]:
Expand All @@ -445,9 +442,9 @@ def complete(self, text, state):
if os.path.isdir(entry_path):
matching_entries.append(entry_path + os.path.sep)
#
for s in matching_entries:
if s.lower().startswith(remainder.lower()) or shlex.quote(s).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(s))
for m in matching_entries:
if m.lower().startswith(remainder.lower()) or shlex.quote(m).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(m))

# Autocomplete local_file
if "local_file" in self.commands[command]["autocomplete"]:
Expand All @@ -468,16 +465,15 @@ def complete(self, text, state):
if not os.path.isdir(entry_path):
matching_entries.append(entry_path)
#
for s in matching_entries:
if s.lower().startswith(remainder.lower()) or shlex.quote(s).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(s))
for m in matching_entries:
if m.lower().startswith(remainder.lower()) or shlex.quote(m).lower().startswith(remainder.lower()):
self.matches.append(command + " " + shlex.quote(m))

else:
# Generic case for subcommands
for s in self.commands[command]["subcommands"]:
if s.startswith(remainder):
self.matches.append(command + " " + s)

for m in self.commands[command]["subcommands"]:
if m.startswith(remainder):
self.matches.append(command + " " + m)
else:
# Unknown subcommand, skipping autocomplete
pass
Expand Down

0 comments on commit 2ec17d3

Please sign in to comment.