diff --git a/code/__DEFINES/computer4_defines.dm b/code/__DEFINES/computer4_defines.dm
index 661abb171df5..c18764ef04fa 100644
--- a/code/__DEFINES/computer4_defines.dm
+++ b/code/__DEFINES/computer4_defines.dm
@@ -28,6 +28,8 @@
#define WIRELESS_FILTER_MODEMAX 2 //! Max of WIRELESS_FILTER_* Defines.
// ThinkDOS //
+// Well-Known Directories
+#define THINKDOS_BIN_DIRECTORY "/bin"
// Constants
#define THINKDOS_MAX_COMMANDS 3 //! The maximum amount of commands
// Symbols
diff --git a/code/modules/computer4/computer4.dm b/code/modules/computer4/computer4.dm
index f7289b12f7a6..07e463627058 100644
--- a/code/modules/computer4/computer4.dm
+++ b/code/modules/computer4/computer4.dm
@@ -64,8 +64,8 @@ TYPEINFO_DEF(/obj/machinery/computer4)
/// List of peripheral typepaths to install by default.
var/list/default_peripherals
- /// The directory to install them in
- var/default_program_dir = "/bin"
+ /// The directory to install them in.
+ var/default_program_dir = THINKDOS_BIN_DIRECTORY
/// Soundloop. Self explanatory.
var/datum/looping_sound/computer/soundloop
diff --git a/code/modules/computer4/data/shell_stdin.dm b/code/modules/computer4/data/parsed_cmdline.dm
similarity index 89%
rename from code/modules/computer4/data/shell_stdin.dm
rename to code/modules/computer4/data/parsed_cmdline.dm
index c6d5740dce84..cb0ab5edd6c2 100644
--- a/code/modules/computer4/data/shell_stdin.dm
+++ b/code/modules/computer4/data/parsed_cmdline.dm
@@ -1,11 +1,11 @@
/// Struct for the parsed stdin
-/datum/shell_stdin
+/datum/parsed_cmdline
var/raw = ""
var/command = ""
var/list/arguments = list()
var/list/options = list()
-/datum/shell_stdin/New(text)
+/datum/parsed_cmdline/New(text)
arguments = splittext(text, " ")
raw = text
@@ -13,8 +13,8 @@
options = list()
arguments.Cut(1, 2) // Pop out the command itself
- if(length(arguments) == 1)
- return
+ if(!length(arguments))
+ return //Bare command, no use going further.
// Parse out options
for(var/str in arguments)
diff --git a/code/modules/computer4/data/terminal/_terminal_program.dm b/code/modules/computer4/data/terminal/_terminal_program.dm
index bcf7f43ca621..e0ba95f0136f 100644
--- a/code/modules/computer4/data/terminal/_terminal_program.dm
+++ b/code/modules/computer4/data/terminal/_terminal_program.dm
@@ -27,8 +27,10 @@
return TRUE
/// Called when a program is run.
-/datum/c4_file/terminal_program/proc/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system)
- system.clear_screen(TRUE)
+/// Operating systems will have cmdline provided as a raw string.
+/// Normal programs should expect and be passed a parsed_cmdline
+/datum/c4_file/terminal_program/proc/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system, datum/parsed_cmdline/cmdline)
+ return
/// Called when a program is no longer running
/datum/c4_file/terminal_program/proc/on_close(datum/c4_file/terminal_program/operating_system/thinkdos/system)
@@ -51,10 +53,10 @@
return FALSE
/// Helper for splitting stdin into command and arguments.
-/datum/c4_file/terminal_program/proc/parse_std_in(text) as /datum/shell_stdin
- RETURN_TYPE(/datum/shell_stdin)
+/datum/c4_file/terminal_program/proc/parse_cmdline(text) as /datum/parsed_cmdline
+ RETURN_TYPE(/datum/parsed_cmdline)
- return new /datum/shell_stdin(text)
+ return new /datum/parsed_cmdline(text)
/// Called by computers to forward commands from peripherals to programs. Should probably be on OS but oh well.
/datum/c4_file/terminal_program/proc/peripheral_input(obj/item/peripheral/invoker, command, datum/signal/packet)
diff --git a/code/modules/computer4/data/terminal/directive/directman.dm b/code/modules/computer4/data/terminal/directive/directman.dm
index c3c7af4ff3b4..b6a822d8709e 100644
--- a/code/modules/computer4/data/terminal/directive/directman.dm
+++ b/code/modules/computer4/data/terminal/directive/directman.dm
@@ -26,27 +26,28 @@
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
system.println("Error: Unable to locate wireless adapter.")
+ system.clear_screen(TRUE)
view_home()
/datum/c4_file/terminal_program/directman/std_in(text)
. = ..()
- var/datum/shell_stdin/parsed_stdin = parse_std_in(text)
+ var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text)
var/datum/c4_file/terminal_program/operating_system/system = get_os()
system.println(html_encode(text))
- if(home_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(home_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
switch(current_menu)
if(DIRECTMAN_MENU_HOME)
for(var/datum/shell_command/potential_command as anything in main_commands)
- if(potential_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(potential_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
if(DIRECTMAN_MENU_CURRENT)
- var/number = text2num(parsed_stdin.raw)
- if(lowertext(parsed_stdin.raw) == "b")
+ var/number = text2num(parsed_cmdline.raw)
+ if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
view_home()
return TRUE
@@ -58,13 +59,13 @@
return TRUE
if(DIRECTMAN_MENU_ACTIVE_DIRECTIVE)
- if(lowertext(parsed_stdin.raw) == "b")
+ if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
view_current()
return TRUE
if(DIRECTMAN_MENU_NEW_DIRECTIVES)
- var/number = text2num(parsed_stdin.raw)
+ var/number = text2num(parsed_cmdline.raw)
if(!(number in 1 to length(SSdirectives.get_directives_for_selection())))
return
@@ -76,7 +77,7 @@
return TRUE
if(DIRECTMAN_MENU_NEW_DIRECTIVE)
- if(lowertext(parsed_stdin.raw) == "b")
+ if(lowertext(parsed_cmdline.raw) == "b")
system.clear_screen(TRUE)
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
view_home()
@@ -86,7 +87,7 @@
return TRUE
- if(lowertext(parsed_stdin.raw) == "s")
+ if(lowertext(parsed_cmdline.raw) == "s")
if(!system.get_computer().get_peripheral(PERIPHERAL_TYPE_WIRELESS_CARD))
view_home()
system.println("Error: Unable to locate wireless adapter.")
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak.dm b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
index fd8688a948f0..14d57b2effc3 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak.dm
@@ -63,6 +63,7 @@
write_log("[system.current_user.registered_name] accessed the records database.")
+ system.clear_screen(TRUE)
home_text()
/// Getter for the log file. This isn't kept as a ref because I don't want to manage the ref. :)
@@ -98,24 +99,24 @@
return
var/datum/c4_file/terminal_program/operating_system/thinkdos/system = get_os()
- var/datum/shell_stdin/parsed_stdin = parse_std_in(text)
+ var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text)
if(awaiting_input)
var/datum/callback/_awaiting = awaiting_input // Null beforehand incase the awaiting input awaits another input.
awaiting_input = null
- _awaiting.Invoke(src, parsed_stdin)
+ _awaiting.Invoke(src, parsed_cmdline)
return
- var/lowertext_command = lowertext(parsed_stdin.command)
+ var/lowertext_command = lowertext(parsed_cmdline.command)
switch(current_menu)
if(MEDTRAK_MENU_HOME)
for(var/datum/shell_command/command as anything in home_commands)
- if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
if(MEDTRAK_MENU_INDEX)
- var/input_num = text2num(parsed_stdin.command)
+ var/input_num = text2num(parsed_cmdline.command)
if(isnum(input_num))
if(input_num == 0)
view_home()
@@ -131,11 +132,11 @@
return TRUE
for(var/datum/shell_command/command as anything in index_commands)
- if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
if(MEDTRAK_MENU_RECORD)
- var/input_num = text2num(parsed_stdin.command)
+ var/input_num = text2num(parsed_cmdline.command)
if(isnum(input_num))
if(input_num == 0)
view_index()
@@ -145,12 +146,12 @@
return TRUE
for(var/datum/shell_command/command as anything in record_commands)
- if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
if(MEDTRAK_MENU_COMMENTS)
for(var/datum/shell_command/command as anything in comment_commands)
- if(command.try_exec(lowertext_command, system, src, parsed_stdin.arguments, parsed_stdin.options))
+ if(command.try_exec(lowertext_command, system, src, parsed_cmdline.arguments, parsed_cmdline.options))
return TRUE
/// Prints the home menu options
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak_comment_commands.dm b/code/modules/computer4/data/terminal/medtrak/medtrak_comment_commands.dm
index 74b4fd9fabb4..3fac2443d78c 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak_comment_commands.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak_comment_commands.dm
@@ -19,7 +19,7 @@
var/datum/c4_file/terminal_program/medtrak/medtrak = program
medtrak.await_input("Enter a new comment", CALLBACK(src, PROC_REF(fulfill_new_comment)))
-/datum/shell_command/medtrak/comment/new_comment/proc/fulfill_new_comment(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/shell_command/medtrak/comment/new_comment/proc/fulfill_new_comment(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/datum/c4_file/terminal_program/operating_system/thinkdos/system = medtrak.get_os()
if(!length(stdin.raw))
medtrak.view_comments()
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak_edit_record.dm b/code/modules/computer4/data/terminal/medtrak/medtrak_edit_record.dm
index c526c5cd949d..0bdc6fb99c3d 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak_edit_record.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak_edit_record.dm
@@ -1,4 +1,4 @@
-/datum/c4_file/terminal_program/medtrak/proc/edit_name(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_name(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_name = trim(html_encode(stdin.raw), MAX_NAME_LEN)
if(!(length(new_name)))
@@ -8,7 +8,7 @@
medtrak.update_record(DATACORE_NAME, "NAME", new_name)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_sex(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_sex(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_sex = trim(html_encode(stdin.raw), MAX_NAME_LEN)
if(!length(new_sex))
@@ -18,7 +18,7 @@
medtrak.update_record(DATACORE_GENDER, "SEX", new_sex)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_age(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_age(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_age = text2num(ckey(stdin.raw))
if(isnull(new_age) || !(new_age in 1 to 200))
@@ -28,7 +28,7 @@
medtrak.update_record(DATACORE_AGE, "AGE", "[new_age]")
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_species(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_species(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_species = trim(html_encode(stdin.raw), MAX_NAME_LEN)
if(!length(new_species))
@@ -38,7 +38,7 @@
medtrak.update_record(DATACORE_SPECIES, "SPECIES", new_species)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_blood_type(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_blood_type(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_blood_type = trim(html_encode(stdin.raw), MAX_NAME_LEN)
if(!length(new_blood_type))
@@ -48,7 +48,7 @@
medtrak.update_record(DATACORE_BLOOD_TYPE, "BLOOD_TYPE", new_blood_type)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_blood_dna(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_blood_dna(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_blood_dna = trim(html_encode(stdin.raw), MAX_NAME_LEN)
if(!length(new_blood_dna))
@@ -58,7 +58,7 @@
medtrak.update_record(DATACORE_BLOOD_DNA, "BLOOD_DNA", new_blood_dna)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_disabilities(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_disabilities(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_disabilities = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)
if(!length(new_disabilities))
@@ -68,7 +68,7 @@
medtrak.update_record(DATACORE_DISABILITIES, "DISABILITIES", new_disabilities)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_diseases(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_diseases(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_diseases = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)
if(!length(new_diseases))
@@ -78,7 +78,7 @@
medtrak.update_record(DATACORE_DISEASES, "DISEASES", new_diseases)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_allergies(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_allergies(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_allergies = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)
if(!length(new_allergies))
@@ -88,7 +88,7 @@
medtrak.update_record(DATACORE_ALLERGIES, "ALLERGIES", new_allergies)
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_physical_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_physical_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/choice = text2num(stdin.raw)
var/list/options = list(
PHYSHEALTH_OK,
@@ -110,7 +110,7 @@
medtrak.update_record(DATACORE_PHYSICAL_HEALTH, "PHYSICAL_STATUS", options[choice])
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_mental_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_mental_health(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/choice = text2num(stdin.raw)
var/list/options = list(
MENHEALTH_OK,
@@ -134,7 +134,7 @@
medtrak.update_record(DATACORE_MENTAL_HEALTH, "MENTAL_STATUS", options[choice])
medtrak.view_record()
-/datum/c4_file/terminal_program/medtrak/proc/edit_notes(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/c4_file/terminal_program/medtrak/proc/edit_notes(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/new_notes = trim(html_encode(stdin.raw), MAX_MESSAGE_LEN)
if(!length(new_notes))
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak_menu_commands.dm b/code/modules/computer4/data/terminal/medtrak/medtrak_menu_commands.dm
index 05d5ef29ea02..46f9c29ce9ba 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak_menu_commands.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak_menu_commands.dm
@@ -19,7 +19,7 @@
var/datum/c4_file/terminal_program/medtrak/medtrak = program
medtrak.await_input("Enter target Name, or ID.", CALLBACK(src, PROC_REF(search_input)))
-/datum/shell_command/medtrak/home/search/proc/search_input(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/shell_command/medtrak/home/search/proc/search_input(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/search_text = stdin.raw
if(isnull(search_text))
medtrak.view_home()
@@ -52,7 +52,7 @@
medtrak.await_input(jointext(out, "
"), CALLBACK(src, PROC_REF(fulfill_search), results))
return
-/datum/shell_command/medtrak/home/search/proc/fulfill_search(list/results, datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/shell_command/medtrak/home/search/proc/fulfill_search(list/results, datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
var/number = text2num(ckey(stdin.raw))
if(isnull(number) || !(number in 1 to length(results)))
medtrak.view_home()
diff --git a/code/modules/computer4/data/terminal/medtrak/medtrak_record_commands.dm b/code/modules/computer4/data/terminal/medtrak/medtrak_record_commands.dm
index 9d23e08aa1d2..9c64a13fd9e9 100644
--- a/code/modules/computer4/data/terminal/medtrak/medtrak_record_commands.dm
+++ b/code/modules/computer4/data/terminal/medtrak/medtrak_record_commands.dm
@@ -34,7 +34,7 @@
medtrak.view_record(medtrak.current_record)
medtrak.await_input("Are you sure you want to delete '[medtrak.current_record.fields[DATACORE_NAME]]'?(Y/N)", CALLBACK(src, PROC_REF(confirm_delete), medtrak))
-/datum/shell_command/medtrak/record/delete/proc/confirm_delete(datum/c4_file/terminal_program/medtrak/medtrak, datum/shell_stdin/stdin)
+/datum/shell_command/medtrak/record/delete/proc/confirm_delete(datum/c4_file/terminal_program/medtrak/medtrak, datum/parsed_cmdline/stdin)
switch(lowertext(jointext(stdin.raw, "")))
if("y")
medtrak.write_log("Record [medtrak.current_record.fields[DATACORE_ID]] deleted.")
diff --git a/code/modules/computer4/data/terminal/netpage/netpage.dm b/code/modules/computer4/data/terminal/netpage/netpage.dm
index 67b7e0fade6c..593fdad348c8 100644
--- a/code/modules/computer4/data/terminal/netpage/netpage.dm
+++ b/code/modules/computer4/data/terminal/netpage/netpage.dm
@@ -22,6 +22,7 @@
if(.)
return
+ system.clear_screen(TRUE)
var/title_text = list(
@"
___ ___ __ __ ___", @"
|\ | |__ | |__) /\ / _` |__", @@ -34,13 +35,13 @@ /datum/c4_file/terminal_program/netpage/std_in(text) . = ..() - var/datum/shell_stdin/parsed_stdin = parse_std_in(text) + var/datum/parsed_cmdline/parsed_cmdline = parse_cmdline(text) var/datum/c4_file/terminal_program/operating_system/system = get_os() system.println(html_encode(text)) for(var/datum/shell_command/potential_command as anything in commands) - if(potential_command.try_exec(parsed_stdin.command, system, src, parsed_stdin.arguments, parsed_stdin.options)) + if(potential_command.try_exec(parsed_cmdline.command, system, src, parsed_cmdline.arguments, parsed_cmdline.options)) return TRUE /datum/c4_file/terminal_program/netpage/proc/check_for_errors() diff --git a/code/modules/computer4/data/terminal/notepad/notepad.dm b/code/modules/computer4/data/terminal/notepad/notepad.dm index 916fe496e289..6fa24200ab38 100644 --- a/code/modules/computer4/data/terminal/notepad/notepad.dm +++ b/code/modules/computer4/data/terminal/notepad/notepad.dm @@ -31,15 +31,16 @@ @"
/ / / ) / ' / / / ) / ' /(", @"
_/____/___(___/_(___ _/____/___(___/_(___ _/___\__", ).Join("") + system.clear_screen(TRUE) system.println(title_text) system.println("Welcome to DocDock, type !help to get started.") -/datum/c4_file/terminal_program/notepad/parse_std_in(text) +/datum/c4_file/terminal_program/notepad/parse_cmdline(text) return splittext(text, " ") /datum/c4_file/terminal_program/notepad/std_in(text) . = ..() - var/list/arguments = parse_std_in(text) + var/list/arguments = parse_cmdline(text) var/command = arguments[1] arguments.Cut(1,2) diff --git a/code/modules/computer4/data/terminal/operating_system.dm b/code/modules/computer4/data/terminal/operating_system.dm index 7437791d825a..02c84426ad4c 100644 --- a/code/modules/computer4/data/terminal/operating_system.dm +++ b/code/modules/computer4/data/terminal/operating_system.dm @@ -146,7 +146,7 @@ get_computer()?.operating_system = null /// Run a program. -/datum/c4_file/terminal_program/operating_system/proc/execute_program(datum/c4_file/terminal_program/program) +/datum/c4_file/terminal_program/operating_system/proc/execute_program(datum/c4_file/terminal_program/program, datum/parsed_cmdline/cmdline) if(!program) return FALSE @@ -155,9 +155,8 @@ if(!(program in processing_programs)) add_processing_program(program) - set_active_program(program) - program.execute(src) + program.execute(src, cmdline) return TRUE /// Close a program. diff --git a/code/modules/computer4/data/terminal/probe/probe.dm b/code/modules/computer4/data/terminal/probe/probe.dm index 22048c7966c1..bf154cf32df5 100644 --- a/code/modules/computer4/data/terminal/probe/probe.dm +++ b/code/modules/computer4/data/terminal/probe/probe.dm @@ -11,11 +11,13 @@ for(var/path as anything in subtypesof(/datum/shell_command/probe_cmd)) commands += new path -/datum/c4_file/terminal_program/probe/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system) +/datum/c4_file/terminal_program/probe/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system, cmdline) . = ..() if(!.) return + //If we have a cmdline, skip the printline. + system.println("NetProbe V2.4", FALSE) system.println("Welcome to NetProbe, type 'help' to get started.") @@ -34,7 +36,7 @@ get_os().println(text) - var/datum/shell_stdin/parsed_input = parse_std_in(text) + var/datum/parsed_cmdline/parsed_input = parse_cmdline(text) var/datum/c4_file/terminal_program/operating_system/os = get_os() diff --git a/code/modules/computer4/data/terminal/test_progs/flagtest.dm b/code/modules/computer4/data/terminal/test_progs/flagtest.dm new file mode 100644 index 000000000000..dca1e6cec921 --- /dev/null +++ b/code/modules/computer4/data/terminal/test_progs/flagtest.dm @@ -0,0 +1,21 @@ +//Dumps the cmdline information it's called with. +/datum/c4_file/terminal_program/cmdline_test + name = "dbg_cmdline" + size = 1 + +/datum/c4_file/terminal_program/cmdline_test/execute(datum/c4_file/terminal_program/operating_system/thinkdos/system, cmdline) + var/datum/parsed_cmdline/lines = cmdline + //Assure that we have a parsed cmdline + if(!istype(lines)) + lines = new /datum/parsed_cmdline(cmdline) + + //Print our cmdline data + system.println(json_encode(list( + "raw" = lines.raw, + "command" = lines.command, + "args" = lines.arguments, + "opts" = lines.options + ), JSON_PRETTY_PRINT)) + //And exit. + system.unload_program(src) + return diff --git a/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm b/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm index 5cc1f8c6bc57..1fa7e3ef8682 100644 --- a/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm +++ b/code/modules/computer4/data/terminal/thinkdos/thinkdos.dm @@ -13,7 +13,7 @@ var/static/list/commands /// Lazy queue of shell commands. When the system is active, it will try to run these. - var/list/datum/shell_stdin/queued_commands + var/list/datum/parsed_cmdline/queued_commands /// Boolean, determines if errors are written to the log file. var/log_errors = TRUE @@ -55,8 +55,8 @@ else println("Type 'help' to get started.") -/datum/c4_file/terminal_program/operating_system/thinkdos/parse_std_in(text) - RETURN_TYPE(/list/datum/shell_stdin) +/datum/c4_file/terminal_program/operating_system/thinkdos/parse_cmdline(text) + RETURN_TYPE(/list/datum/parsed_cmdline) var/list/split_raw = splittext(text, THINKDOS_SYMBOL_SEPARATOR) if(length(split_raw) > THINKDOS_MAX_COMMANDS) @@ -66,7 +66,7 @@ . = list() for(var/raw_command in split_raw) - . += new /datum/shell_stdin(trimtext(raw_command)) //built-in is faster, don't care about right whitespace + . += new /datum/parsed_cmdline(trimtext(raw_command)) //built-in is faster, don't care about right whitespace /datum/c4_file/terminal_program/operating_system/thinkdos/std_in(text) . = ..() @@ -77,18 +77,18 @@ println(encoded_in) write_log(encoded_in) - var/list/datum/shell_stdin/parsed_stdins = parse_std_in(text) - if(!length(parsed_stdins)) //okay + var/list/datum/parsed_cmdline/parsed_cmdlines = parse_cmdline(text) + if(!length(parsed_cmdlines)) //okay return TRUE if(!current_user && needs_login) - var/datum/shell_stdin/login_stdin = parsed_stdins[1] + var/datum/parsed_cmdline/login_stdin = parsed_cmdlines[1] var/datum/shell_command/thinkdos/login/login_command = locate() in commands if(!login_command.try_exec(login_stdin.command, src, src, login_stdin.arguments, login_stdin.options)) println("Login required. Please login using 'login'.") return - queued_commands = parsed_stdins + queued_commands = parsed_cmdlines handle_command_queue() return TRUE @@ -103,15 +103,30 @@ if(active_program != src) //We are now blocking break - var/datum/shell_stdin/parsed_stdin = popleft(queued_commands) + var/datum/parsed_cmdline/parsed_cmdline = popleft(queued_commands) var/recognized = FALSE for(var/datum/shell_command/potential_command as anything in commands) - if(potential_command.try_exec(parsed_stdin.command, src, src, parsed_stdin.arguments, parsed_stdin.options)) + if(potential_command.try_exec(parsed_cmdline.command, src, src, parsed_cmdline.arguments, parsed_cmdline.options)) recognized = TRUE break + // Check if we executed a shell command, if so, break out of the while loop. + if(recognized) + continue //We aren't being re-called from unload_program(), so we have to loop back to the start here. + // Otherwise, Search the local directory for a matching program + // Argument passing doesn't exist for programs so we can just ignore it. + var/datum/c4_file/terminal_program/program_to_run = resolve_filepath(parsed_cmdline.command) + if(!istype(program_to_run) || istype(program_to_run, /datum/c4_file/terminal_program/operating_system)) + // If that one's not good, Search the bin directory for a matching program + program_to_run = resolve_filepath(parsed_cmdline.command, get_bin_folder()) + + if(istype(program_to_run) && !istype(program_to_run, /datum/c4_file/terminal_program/operating_system)) + execute_program(program_to_run, parsed_cmdline) //This will block command queue execution. + recognized = TRUE + break + if(!recognized) - println("'[html_encode(parsed_stdin.raw)]' is not recognized as an internal or external command.") + println("'[html_encode(parsed_cmdline.raw)]' is not recognized as an internal or external command.") UNSETEMPTY(queued_commands) @@ -216,6 +231,13 @@ return log_dir +/// Get the bin folder. The bin directory holds normal programs. +/datum/c4_file/terminal_program/operating_system/thinkdos/proc/get_bin_folder() + //the `/bin` part here is technically supposed to be reading the physical computer's default program dir. + //But that's dumb and /bin should always be correct. + return parse_directory(THINKDOS_BIN_DIRECTORY, drive.root, FALSE) + + /// Create the log file, or append a startup log. /datum/c4_file/terminal_program/operating_system/thinkdos/proc/initialize_logs() if(command_log) @@ -236,6 +258,8 @@ log_file.data += "