Skip to content

Commit

Permalink
Update fs.rb
Browse files Browse the repository at this point in the history
Added lmkdir command to create new directory on local machine
  • Loading branch information
e-lliot authored Sep 20, 2023
1 parent 1ef030d commit f28e0d9
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def commands
'getwd' => 'Print working directory',
'lcat' => 'Read the contents of a local file to the screen',
'lcd' => 'Change local working directory',
'lmkdir' => 'Create new directory on local machine',
'lpwd' => 'Print local working directory',
'ls' => 'List files',
'lls' => 'List local files',
Expand Down Expand Up @@ -117,6 +118,7 @@ def commands
'getwd' => [COMMAND_ID_STDAPI_FS_GETWD],
'lcat' => [],
'lcd' => [],
'lmkdir' => [],
'lpwd' => [],
'ls' => [COMMAND_ID_STDAPI_FS_STAT, COMMAND_ID_STDAPI_FS_LS],
'lls' => [],
Expand Down Expand Up @@ -383,6 +385,22 @@ def cmd_lcd(*args)
return true
end

def cmd_lmkdir(*args)
if (args.length == 0)
print_line("Usage: lmkdir directory")
return true
end

begin
::Dir.mkdir(args[0])
print_line("Directory '#{args[0]}' created successfully.")
rescue => e
print_error("Error creating directory: #{e}")
end

return true
end

#
# Tab completion for the lcd command
#
Expand Down

0 comments on commit f28e0d9

Please sign in to comment.