Skip to content

Commit

Permalink
Implemented 'lrename' command, fixed #10
Browse files Browse the repository at this point in the history
  • Loading branch information
p0dalirius committed Jun 4, 2024
1 parent a14eff9 commit d00c148
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
7 changes: 7 additions & 0 deletions smbclientng/core/CommandCompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ class CommandCompleter(object):
],
"subcommands": []
},
"lrename": {
"description": [
"Renames a local file.",
"Syntax: 'lrename <oldfilename> <newfilename>'"
],
"subcommands": []
},
"lrm": {
"description": [
"Removes a local file.",
Expand Down
16 changes: 15 additions & 1 deletion smbclientng/core/InteractiveShell.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ def process_command(self, command, arguments=[]):
elif command == "lpwd":
self.command_lpwd(arguments, command)

# Renames a local file
elif command == "lrename":
self.command_lrename(arguments, command)

# Removes a local file
elif command == "lrm":
self.command_lrm(arguments, command)
Expand Down Expand Up @@ -444,6 +448,17 @@ def command_lpwd(self, arguments, command):

print(os.getcwd())

@command_arguments_required
def command_lrename(self, arguments, command):
# Command arguments required : Yes
# Active SMB connection needed : No
# SMB share needed : No

if len(arguments) == 2:
os.rename(src=arguments[0], dst=arguments[1])
else:
self.commandCompleterObject.print_help(command=command)

@command_arguments_required
def command_lrm(self, arguments, command):
# Command arguments required : Yes
Expand Down Expand Up @@ -669,7 +684,6 @@ def command_use(self, arguments, command):

def __load_modules(self):


self.modules.clear()

modules_dir = os.path.normpath(os.path.dirname(__file__) + os.path.sep + ".." + os.path.sep + "modules")
Expand Down

0 comments on commit d00c148

Please sign in to comment.