blob: efa3353394258d0d5605b803659f0be14f1aa98b (
plain)
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
|
/*
* GNU AFFERO GENERAL PUBLIC LICENSE
* Version 3, 19 November 2007
* Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
using System;
using System.CommandLine;
using System.IO;
using System.Text.Json;
using UVtools.Core.Extensions;
using UVtools.Core.FileFormats;
using UVtools.Core.Printer;
namespace UVtools.Cmd.Symbols;
internal static class PrintMachinesCommand
{
internal static Command CreateCommand()
{
var jsonOption = new Option<bool>("--json", "Print in json format");
var xmlOption = new Option<bool>("--xml", "Print in xml format");
var command = new Command("print-machines", "Prints machine settings")
{
jsonOption,
xmlOption
};
command.SetHandler((jsonFormat, xmlFormat) =>
{
if (jsonFormat)
{
Console.WriteLine(JsonSerializer.Serialize(Machine.Machines, JsonExtensions.SettingsIndent));
return;
}
if (xmlFormat)
{
Console.WriteLine(XmlExtensions.SerializeObject(Machine.Machines, XmlExtensions.SettingsIndent));
return;
}
foreach (var machine in Machine.Machines)
{
Console.WriteLine(machine);
}
}, jsonOption, xmlOption);
return command;
}
}
|