forked from fluffy-mods/SteamWorkshopUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
83 lines (72 loc) · 2.84 KB
/
Program.cs
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
83
using System;
using System.IO;
using SteamWorkshopUploader;
namespace SteamWorkshopUpdater
{
using System.Linq;
class Program
{
static void Main(string[] args)
{
if ( args.Length < 1 || args.Length > 4 || args[0] == "-h" )
{
Console.WriteLine( @"Usage:
SteamWorkshopUpdater.exe [path_to_mod] [changenote] [description] [contributor]
Options:
path_to_mod Fully qualified path to the mod's base directory. (required)
changenote Either a fully qualified path to a file, in which case (optional)
the changenote will be read from that file, or a string
changenote. If not set, will default to the current
timestamp.
description Fully qualified path to a file, the contents of which (optional)
will be used as the item's description. If not set, will
default to description given in About.xml.
contributor Use if you are a listed as a contributor to the mod (optional)
and not the original uploader.");
return;
}
try
{
bool originalUploader = args.All(x => x != "contributor");
var mod = new Mod( args[0], originalUploader);
if ( args.Length >= 3 && args[2] != null && File.Exists( args[2] ) )
{
// read file for description
mod.Description = File.ReadAllText( args[2] );
}
string changenote;
if ( args.Length >= 2 && args[1] != null && args[1] != "contributor")
{
// if file, read from file - otherwise set changenote
if ( File.Exists( args[1] ) )
changenote = File.ReadAllText( args[1] );
else
changenote = args[1];
}
else
{
// fall back on default changenote
changenote = "[Auto-generated text]: Update on " + DateTime.Now + ".";
}
// Console.WriteLine( mod + "\nChangenote: " + changenote );
Uploader.Init();
if ( Uploader.Upload( mod, changenote ) )
{
Console.WriteLine( "Upload done: https://steamcommunity.com/sharedfiles/filedetails/changelog/" + mod.PublishedFileId );
}
else
{
Console.WriteLine( "Upload failed :(" );
}
}
catch ( Exception e )
{
Console.WriteLine( e.Message );
}
finally
{
Uploader.Shutdown();
}
}
}
}