Skip to content

Commit be72e51

Browse files
committed
lc 2.1.0
1 parent 367f8eb commit be72e51

File tree

7 files changed

+48
-41
lines changed

7 files changed

+48
-41
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ Debug
33
obj
44
*.exe
55
*.dll
6-
*.lcpkg
6+
*.lcp

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ apkg get hacks
1919

2020
- `chlcpw`: view and change user details
2121
- `crash`: immediatly exit LeoConsole
22+
- `info`: print some data about running LeoConsole instance
2223

chlcpw.cs

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -8,38 +8,40 @@ namespace LeoConsole_Hacks {
88
public class CHLCPW : ICommand {
99
public string Name { get { return "chlcpw"; } }
1010
public string Description { get { return "manipulate passwords and stuff lol"; } }
11-
public Action CommandFunktion { get { return () => Command(); } }
12-
private string[] _InputProperties;
13-
public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } }
11+
public Action CommandFunction { get { return () => Command(); } }
12+
public Action HelpFunction { get { return () => help(); } }
13+
private string[] _Arguments;
14+
public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } }
1415
public IData data = new ConsoleData();
1516
private string usersFile;
1617

1718
public void Command() {
1819
usersFile = Path.Join(data.SavePath, "user", "Users.lcs");
1920
if (!File.Exists(usersFile)) {
20-
Console.WriteLine("for some reason, the users file at " + usersFile + " seems not to exist");
21+
LConsole.MessageErr0("for some reason, the users file at " + usersFile + " seems not to exist");
2122
return;
2223
}
23-
if (_InputProperties.Length < 2) {
24+
if (_Arguments.Length < 2) {
2425
help();
2526
return;
2627
}
27-
switch (_InputProperties[1]) {
28+
switch (_Arguments[1]) {
2829
case "help": help(); break;
2930
case "show": show(); break;
3031
case "edit": edit(); break;
31-
default: Console.WriteLine("unrecognized argument: " + _InputProperties[1]); help(); break;
32+
default: LConsole.MessageErr0("unrecognized argument: " + _Arguments[1]); help(); break;
3233
}
3334
}
3435

3536
private void help() {
36-
Console.WriteLine("chlcpw - CHange LeoConsole PassWord");
37-
Console.WriteLine("see and change LeoConsole user details (inspired by chntpw)");
38-
Console.WriteLine("");
39-
Console.WriteLine("arguments:");
40-
Console.WriteLine(" help: show this help");
41-
Console.WriteLine(" show: list user details");
42-
Console.WriteLine(" edit <username> <field> <value>: change user details");
37+
Console.WriteLine(@"
38+
chlcpw - CHange LeoConsole PassWord
39+
see and change LeoConsole user details (inspired by chntpw)
40+
41+
arguments:
42+
help: show this help
43+
show: list user details
44+
edit <username> <field> <value>: change user details");
4345
}
4446

4547
private List<User> getUsersList() {
@@ -50,7 +52,7 @@ private List<User> getUsersList() {
5052
stream.Close();
5153
return users;
5254
} catch (Exception e) {
53-
Console.WriteLine("cannot read users list: " + e.Message);
55+
LConsole.MessageErr0("cannot read users list: " + e.Message);
5456
return new List<User>();
5557
}
5658
}
@@ -75,8 +77,8 @@ private void show() {
7577
}
7678

7779
private void edit() {
78-
if (_InputProperties.Length < 4) {
79-
Console.WriteLine("not enough arguments");
80+
if (_Arguments.Length < 4) {
81+
LConsole.MessageErr0("not enough arguments");
8082
return;
8183
}
8284

@@ -85,41 +87,41 @@ private void edit() {
8587
return;
8688
}
8789

88-
Console.WriteLine("Working with user " + _InputProperties[2]);
90+
LConsole.MessageSuc0("Working with user " + _Arguments[2]);
8991
for (int i = 0; i <= users.Count - 1; i++) {
90-
if (users[i].name != _InputProperties[2]) {
92+
if (users[i].name != _Arguments[2]) {
9193
continue;
9294
}
93-
switch (_InputProperties[3]) {
95+
switch (_Arguments[3]) {
9496
case "name":
95-
Console.WriteLine("changing username from " + users[i].name + " to " + _InputProperties[4]);
96-
users[i].name = _InputProperties[4];
97+
LConsole.MessageSuc1("changing username from " + users[i].name + " to " + _Arguments[4]);
98+
users[i].name = _Arguments[4];
9799
break;
98100
case "password":
99-
Console.WriteLine("changing password to " + _InputProperties[4]);
100-
users[i].password = _InputProperties[4];
101+
LConsole.MessageSuc1("changing password to " + _Arguments[4]);
102+
users[i].password = _Arguments[4];
101103
break;
102104
case "greeting":
103-
Console.WriteLine("changing greeting from '" + users[i].begrüßung + "' to '" + _InputProperties[4] + "'");
104-
users[i].begrüßung = _InputProperties[4];
105+
LConsole.MessageSuc1("changing greeting from '" + users[i].begrüßung + "' to '" + _Arguments[4] + "'");
106+
users[i].begrüßung = _Arguments[4];
105107
break;
106108
case "root":
107-
if (_InputProperties[4] == "yes") {
108-
Console.WriteLine("setting user to root");
109+
if (_Arguments[4] == "yes") {
110+
LConsole.MessageSuc1("setting user to root");
109111
users[i].root = true;
110112
} else {
111-
Console.WriteLine("setting user to non-root");
113+
LConsole.MessageSuc1("setting user to non-root");
112114
users[i].root = false;
113115
}
114116
break;
115117
default:
116-
Console.WriteLine("invalid field: " + _InputProperties[3]);
118+
LConsole.MessageErr0("invalid field: " + _Arguments[3]);
117119
return;
118120
break;
119121
}
120122
}
121123

122-
Console.WriteLine("saving new user table");
124+
LConsole.MessageSuc0("saving new user table");
123125
BinaryFormatter formatter = new BinaryFormatter();
124126
FileStream stream = new FileStream(usersFile, FileMode.Create);
125127
formatter.Serialize(stream, users);

crash.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ namespace LeoConsole_Hacks {
66
public class Crash : ICommand {
77
public string Name { get { return "crash"; } }
88
public string Description { get { return "crash LeoConsole"; } }
9-
public Action CommandFunktion { get { return () => Command(); } }
10-
private string[] _InputProperties;
11-
public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } }
9+
public Action CommandFunction { get { return () => Command(); } }
10+
public Action HelpFunction { get { return () => Console.WriteLine("HAHA self documenting code"); } }
11+
private string[] _Arguments;
12+
public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } }
1213
public IData data = new ConsoleData();
1314
private string usersFile;
1415

info.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ namespace LeoConsole_Hacks {
66
public class Info : ICommand {
77
public string Name { get { return "info"; } }
88
public string Description { get { return "print some data about the running LeoConsole instance"; } }
9-
public Action CommandFunktion { get { return () => Command(); } }
10-
private string[] _InputProperties;
11-
public string[] InputProperties { get { return _InputProperties; } set { _InputProperties = value; } }
9+
public Action CommandFunction { get { return () => Command(); } }
10+
public Action HelpFunction { get { return () => Console.WriteLine("print some data about running LC instance"); } }
11+
private string[] _Arguments;
12+
public string[] Arguments { get { return _Arguments; } set { _Arguments = value; } }
1213
public IData data = new ConsoleData();
1314
private string usersFile;
1415

1516
public void Command() {
1617
Console.Write(data.Version);
17-
Environment.Exit(1);
1818
}
1919
}
2020
}

manifest.apkg.json renamed to manifest.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
{
2-
"manifestVersion": 2.1,
2+
"manifestVersion": 3.0,
33
"packageName": "hacks",
4-
"packageVersion": "1.0.0",
4+
"packageVersion": "1.0.1",
5+
"depends": [],
6+
"compatibleVersions": ["2.1.0"],
57
"build": {
68
"command": "dotnet",
79
"args": ["build", "--nologo"],

plugin.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ public void PluginInit() {
3535
public void RegisterCommands(){
3636
_Commands.Add(new CHLCPW());
3737
_Commands.Add(new Crash());
38+
_Commands.Add(new Info());
3839
}
3940

4041
public void PluginMain() { }

0 commit comments

Comments
 (0)