-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
82 lines (72 loc) · 3 KB
/
Program.cs
File metadata and controls
82 lines (72 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
namespace pdutil;
internal class Program
{
private static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Usage: pdutil2 <action> [options]");
Console.WriteLine(" datadisk - Mount Playdate data partition");
Console.WriteLine(" install <pdx-path or zip> - Install .pdx to device (only copying newer)");
Console.WriteLine(" clean <pdx-path or zip> - Clean install .pdx to device");
Console.WriteLine(" recoverydisk - Mount Playdate recovery partition");
Console.WriteLine(" run <path> - Run .pdx from device's data partition");
Console.WriteLine(" cmd <command> - Send command to the device");
Console.WriteLine(" shell - Connect to an interactive serial shell");
Console.WriteLine(" screen <filename> - Save a screenshot to filename");
Environment.Exit(0);
}
string command = args[0].ToLower(null);
string arg1 = args.Length >=2 ? args[1] : "";
if (string.IsNullOrWhiteSpace(Playdate.ComPortName))
{
Console.WriteLine("No Playdate device detected.");
Environment.Exit(1);
}
else
Console.WriteLine("Playdate device detected on " + Playdate.ComPortName);
switch (command)
{
case "datadisk":
Playdate.MountDataDisk();
break;
case "install":
case "clean":
if (string.IsNullOrWhiteSpace(arg1))
{
Console.WriteLine("Please provide the name or path to a .pdx or zipped .pdx to install.");
Environment.Exit(1);
}
Playdate.Install(arg1, command == "clean");
break;
case "recoverydisk":
Playdate.MountRecoveryDisk();
break;
case "run":
if (string.IsNullOrWhiteSpace(arg1))
{
Console.WriteLine("Please provide the path to an application on device, such as Games/MyGame.pdx");
Environment.Exit(1);
}
Playdate.Run(arg1);
break;
case "cmd":
if (string.IsNullOrWhiteSpace(arg1))
{
Console.WriteLine("Please provide a command to send to the device, such as help");
Environment.Exit(1);
}
Playdate.Cmd(arg1);
break;
case "shell":
Playdate.Shell();
break;
case "screen":
Playdate.Screen(arg1 ?? "out.png");
break;
default:
Console.WriteLine($"Unknown action \"{command}\".");
break;
}
}
}