Skip to content

Instantly share code, notes, and snippets.

@ninjapanzer
Created March 1, 2016 13:49
Show Gist options
  • Select an option

  • Save ninjapanzer/3130fb144ccc01146393 to your computer and use it in GitHub Desktop.

Select an option

Save ninjapanzer/3130fb144ccc01146393 to your computer and use it in GitHub Desktop.
config editor pseudo
// If we are initializing the file
argv = ["C:/config.exe", "init"]
// If we are editing first_name
argv = ["C:/config.exe", "edit", "cypher"]
BEGIN
if argv[1] == "init"
string first_name = ""
open file "./config" for writing
do
output "Enter first name"
input first_name
while(first_name != "")
output_to_file: "firstname="+first_name
...
...
...
close file "./config" for writing
endif
if argv[1] == "edit"
string first_name;
string last_name;
string cypher;
...
open file "./config" for reading
// This is trivial and not exactly correct. We output to the file with an = betwee nthe data and the label so we would have to deal with that
// The split method would do a goodjob but there are others.
input_from_file: first_name;
input_from_file: last_name;
input_from_file: cypher;
...
close file "./config" for reading
if argv[2] == "first_name"
string replaced_first_name == "";
do
output "Enter first name"
input replaced_first_name
while(replaced_first_name != "")
endif
first_name = replaced_first_name;
endif
if argv[2] == "last_name"
string replaced_last_name == "";
do
output "Enter first name"
input replaced_last_name
while(replaced_last_name != "")
endif
last_name = replaced_last_name;
endif
if argv[2] == "cypher"
string replaced_cypher == "";
do
output "Enter first name"
input replaced_cypher
while(replaced_cypher != "")
endif
cypher = replaced_cypher;
endif
open file "./config" for writing
output_to_file: first_name;
output_to_file: last_name;
output_to_file: cypher;
...
close file "./config" for writing
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment