mirror of
				https://github.com/SquidDev-CC/CC-Tweaked
				synced 2025-10-31 05:33:00 +00:00 
			
		
		
		
	use arg[0] in all usage printouts (#571)
This commit is contained in:
		| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs > 2 then | if #tArgs > 2 then | ||||||
|     print("Usage: alias <alias> <program>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <alias> <program>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: cd <path>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <path>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -4,7 +4,8 @@ if not commands then | |||||||
|     return |     return | ||||||
| end | end | ||||||
| if #tArgs == 0 then | if #tArgs == 0 then | ||||||
|     printError("Usage: exec <command>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     printError("Usage: " .. programName .. " <command>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 2 then | if #tArgs < 2 then | ||||||
|     print("Usage: cp <source> <destination>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <source> <destination>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| local args = table.pack(...) | local args = table.pack(...) | ||||||
|  |  | ||||||
| if args.n < 1 then | if args.n < 1 then | ||||||
|     print("Usage: rm <paths>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <paths>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| -- Get file to edit | -- Get file to edit | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs == 0 then | if #tArgs == 0 then | ||||||
|     print("Usage: edit <path>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <path>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| -- Get arguments | -- Get arguments | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs == 0 then | if #tArgs == 0 then | ||||||
|     print("Usage: eject <drive>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <drive>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -34,7 +34,8 @@ end | |||||||
| -- Determines if the file exists, and can be edited on this computer | -- Determines if the file exists, and can be edited on this computer | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs == 0 then | if #tArgs == 0 then | ||||||
|     print("Usage: paint <path>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <path>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
| local sPath = shell.resolve(tArgs[1]) | local sPath = shell.resolve(tArgs[1]) | ||||||
|   | |||||||
| @@ -1,10 +1,11 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|  |  | ||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("dj play") |     print(programName .. " play") | ||||||
|     print("dj play <drive>") |     print(programName .. " play <drive>") | ||||||
|     print("dj stop") |     print(programName .. " stop") | ||||||
| end | end | ||||||
|  |  | ||||||
| if #tArgs > 2 then | if #tArgs > 2 then | ||||||
|   | |||||||
| @@ -1,8 +1,9 @@ | |||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("gps host") |     print(programName .. " host") | ||||||
|     print("gps host <x> <y> <z>") |     print(programName .. " host <x> <y> <z>") | ||||||
|     print("gps locate") |     print(programName .. " locate") | ||||||
| end | end | ||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|   | |||||||
| @@ -1,8 +1,9 @@ | |||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("pastebin put <filename>") |     print(programName .. " put <filename>") | ||||||
|     print("pastebin get <code> <filename>") |     print(programName .. " get <code> <filename>") | ||||||
|     print("pastebin run <code> <arguments>") |     print(programName .. " run <code> <arguments>") | ||||||
| end | end | ||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usage:") |     print("Usage:") | ||||||
|     print("wget <url> [filename]") |     print(programName .. " <url> [filename]") | ||||||
|     print("wget run <url>") |     print(programName .. " run <url>") | ||||||
| end | end | ||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("label get") |     print(programName .. " get") | ||||||
|     print("label get <drive>") |     print(programName .. " get <drive>") | ||||||
|     print("label set <text>") |     print(programName .. " set <text>") | ||||||
|     print("label set <drive> <text>") |     print(programName .. " set <drive> <text>") | ||||||
|     print("label clear") |     print(programName .. " clear") | ||||||
|     print("label clear <drive>") |     print(programName .. " clear <drive>") | ||||||
| end | end | ||||||
|  |  | ||||||
| local function checkDrive(sDrive) | local function checkDrive(sDrive) | ||||||
|   | |||||||
| @@ -1,7 +1,8 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|  |  | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: mkdir <paths>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <paths>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| local function printUsage() | local function printUsage() | ||||||
|     print("Usage: monitor <name> <program> <arguments>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <name> <program> <arguments>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 2 then | if #tArgs < 2 then | ||||||
|     print("Usage: mv <source> <destination>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <source> <destination>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,9 +1,10 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|  |  | ||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("chat host <hostname>") |     print(programName .. " host <hostname>") | ||||||
|     print("chat join <hostname> <nickname>") |     print(programName .. " join <hostname> <nickname>") | ||||||
| end | end | ||||||
|  |  | ||||||
| local sOpenedModem = nil | local sOpenedModem = nil | ||||||
|   | |||||||
| @@ -1,11 +1,12 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
|  |  | ||||||
| local function printUsage() | local function printUsage() | ||||||
|  |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|     print("Usages:") |     print("Usages:") | ||||||
|     print("redstone probe") |     print(programName .. " probe") | ||||||
|     print("redstone set <side> <value>") |     print(programName .. " set <side> <value>") | ||||||
|     print("redstone set <side> <color> <value>") |     print(programName .. " set <side> <color> <value>") | ||||||
|     print("redstone pulse <side> <count> <period>") |     print(programName .. " pulse <side> <count> <period>") | ||||||
| end | end | ||||||
|  |  | ||||||
| local sCommand = tArgs[1] | local sCommand = tArgs[1] | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 2 then | if #tArgs < 2 then | ||||||
|     print("Usage: rename <source> <destination>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <source> <destination>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -11,7 +11,8 @@ end | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| local nLimit = nil | local nLimit = nil | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: craft [number]") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " [number]") | ||||||
|     return |     return | ||||||
| else | else | ||||||
|     nLimit = tonumber(tArgs[1]) |     nLimit = tonumber(tArgs[1]) | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| local function printUsage() | local function printUsage() | ||||||
|     print("Usage: equip <slot> <side>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <slot> <side>") | ||||||
| end | end | ||||||
|  |  | ||||||
| if #tArgs ~= 2 then | if #tArgs ~= 2 then | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs ~= 1 then | if #tArgs ~= 1 then | ||||||
|     print("Usage: excavate <diameter>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <diameter>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: go <direction> <distance>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <direction> <distance>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,7 +6,8 @@ end | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| local nLimit = 1 | local nLimit = 1 | ||||||
| if #tArgs > 1 then | if #tArgs > 1 then | ||||||
|     print("Usage: refuel [number]") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " [number]") | ||||||
|     return |     return | ||||||
| elseif #tArgs > 0 then | elseif #tArgs > 0 then | ||||||
|     if tArgs[1] == "all" then |     if tArgs[1] == "all" then | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs ~= 1 then | if #tArgs ~= 1 then | ||||||
|     print("Usage: tunnel <length>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <length>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: turn <direction> <turns>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <direction> <turns>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -5,7 +5,8 @@ end | |||||||
|  |  | ||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| local function printUsage() | local function printUsage() | ||||||
|     print("Usage: unequip <side>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <side>") | ||||||
| end | end | ||||||
|  |  | ||||||
| if #tArgs ~= 1 then | if #tArgs ~= 1 then | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| local tArgs = { ... } | local tArgs = { ... } | ||||||
| if #tArgs < 1 then | if #tArgs < 1 then | ||||||
|     print("Usage: type <path>") |     local programName = arg[0] or fs.getName(shell.getRunningProgram()) | ||||||
|  |     print("Usage: " .. programName .. " <path>") | ||||||
|     return |     return | ||||||
| end | end | ||||||
|  |  | ||||||
|   | |||||||
| @@ -10,7 +10,7 @@ describe("The exec program", function() | |||||||
|     it("displays its usage when given no argument", function() |     it("displays its usage when given no argument", function() | ||||||
|         stub(_G, "commands", {}) |         stub(_G, "commands", {}) | ||||||
|         expect(capture(stub, "/rom/programs/command/exec.lua")) |         expect(capture(stub, "/rom/programs/command/exec.lua")) | ||||||
|             :matches { ok = true, output = "", error = "Usage: exec <command>\n" } |             :matches { ok = true, output = "", error = "Usage: /rom/programs/command/exec.lua <command>\n" } | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("runs a command", function() |     it("runs a command", function() | ||||||
|   | |||||||
| @@ -35,6 +35,6 @@ describe("The copy program", function() | |||||||
|  |  | ||||||
|     it("displays the usage when given no arguments", function() |     it("displays the usage when given no arguments", function() | ||||||
|         expect(capture(stub, "copy")) |         expect(capture(stub, "copy")) | ||||||
|             :matches { ok = true, output = "Usage: cp <source> <destination>\n", error = "" } |             :matches { ok = true, output = "Usage: copy <source> <destination>\n", error = "" } | ||||||
|     end) |     end) | ||||||
| end) | end) | ||||||
|   | |||||||
| @@ -69,6 +69,6 @@ describe("The move program", function() | |||||||
|  |  | ||||||
|     it("displays the usage with no arguments", function() |     it("displays the usage with no arguments", function() | ||||||
|         expect(capture(stub, "move")) |         expect(capture(stub, "move")) | ||||||
|             :matches { ok = true, output = "Usage: mv <source> <destination>\n", error = "" } |             :matches { ok = true, output = "Usage: move <source> <destination>\n", error = "" } | ||||||
|     end) |     end) | ||||||
| end) | end) | ||||||
|   | |||||||
| @@ -19,7 +19,7 @@ describe("The craft program", function() | |||||||
|         stub(_G, "turtle", { craft = function() end }) |         stub(_G, "turtle", { craft = function() end }) | ||||||
|  |  | ||||||
|         expect(capture(stub, "/rom/programs/turtle/craft.lua")) |         expect(capture(stub, "/rom/programs/turtle/craft.lua")) | ||||||
|             :matches { ok = true, output = "Usage: craft [number]\n", error = "" } |             :matches { ok = true, output = "Usage: /rom/programs/turtle/craft.lua [number]\n", error = "" } | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("crafts multiple items", function() |     it("crafts multiple items", function() | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ describe("The turtle equip program", function() | |||||||
|         stub(_G, "turtle", {}) |         stub(_G, "turtle", {}) | ||||||
|  |  | ||||||
|         expect(capture(stub, "/rom/programs/turtle/equip.lua")) |         expect(capture(stub, "/rom/programs/turtle/equip.lua")) | ||||||
|             :matches { ok = true, output = "Usage: equip <slot> <side>\n", error = "" } |             :matches { ok = true, output = "Usage: /rom/programs/turtle/equip.lua <slot> <side>\n", error = "" } | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("equip nothing", function() |     it("equip nothing", function() | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ describe("The refuel program", function() | |||||||
|     it("displays its usage when given too many argument", function() |     it("displays its usage when given too many argument", function() | ||||||
|         setup_turtle(0, 5, 0) |         setup_turtle(0, 5, 0) | ||||||
|         expect(capture(stub, "/rom/programs/turtle/refuel.lua a b")) |         expect(capture(stub, "/rom/programs/turtle/refuel.lua a b")) | ||||||
|             :matches { ok = true, output = "Usage: refuel [number]\n", error = "" } |             :matches { ok = true, output = "Usage: /rom/programs/turtle/refuel.lua [number]\n", error = "" } | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("requires a numeric argument", function() |     it("requires a numeric argument", function() | ||||||
|   | |||||||
| @@ -13,7 +13,7 @@ describe("The turtle unequip program", function() | |||||||
|         stub(_G, "turtle", {}) |         stub(_G, "turtle", {}) | ||||||
|  |  | ||||||
|         expect(capture(stub, "/rom/programs/turtle/unequip.lua")) |         expect(capture(stub, "/rom/programs/turtle/unequip.lua")) | ||||||
|             :matches { ok = true, output = "Usage: unequip <side>\n", error = "" } |             :matches { ok = true, output = "Usage: /rom/programs/turtle/unequip.lua <side>\n", error = "" } | ||||||
|     end) |     end) | ||||||
|  |  | ||||||
|     it("says when nothing was unequipped", function() |     it("says when nothing was unequipped", function() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Lupus590
					Lupus590