@@ -12,14 +12,12 @@ internal class Program
12
12
private static string version = System . Reflection . Assembly . GetExecutingAssembly ( ) . GetName ( ) . Version . ToString ( 3 ) ;
13
13
private const string USER = "mattpannella" ;
14
14
private const string REPOSITORY = "pocket-updater-utility" ;
15
- private const string RELEASE_URL = "https://github.com/mattpannella/pocket-updater-utility/releases/download/{0}/pocket_updater_{1}.zip" ;
16
- private const string NEW_RELEASE_URL = "https://github.com/mattpannella/pocket-updater-utility/releases/download/{0}/pupdate_{1}.zip" ;
15
+ private const string RELEASE_URL = "https://github.com/mattpannella/pocket-updater-utility/releases/download/{0}/pupdate_{1}.zip" ;
17
16
private static SettingsManager settings ;
18
17
19
18
private static PocketCoreUpdater updater ;
20
19
21
20
private static bool cliMode = false ;
22
- private static bool migrate = false ;
23
21
private static async Task Main ( string [ ] args )
24
22
{
25
23
try {
@@ -122,6 +120,9 @@ private static async Task Main(string[] args)
122
120
if ( o . InstallPath != null && o . InstallPath != "" ) {
123
121
path = o . InstallPath ;
124
122
}
123
+ if ( o . SkipUpdate ) {
124
+ cliMode = true ;
125
+ }
125
126
}
126
127
)
127
128
. WithNotParsed ( o =>
@@ -136,7 +137,7 @@ private static async Task Main(string[] args)
136
137
) ;
137
138
138
139
if ( ! cliMode ) {
139
- Console . WriteLine ( "Pocket Updater Utility v" + version ) ;
140
+ Console . WriteLine ( "Pupdate v" + version ) ;
140
141
Console . WriteLine ( "Checking for updates..." ) ;
141
142
142
143
if ( await CheckVersion ( path ) && ! selfUpdate ) {
@@ -315,37 +316,16 @@ private static async Task Main(string[] args)
315
316
}
316
317
}
317
318
318
- static void DisplayHelp < T > ( ParserResult < T > result )
319
- {
320
- var helpText = CommandLine . Text . HelpText . AutoBuild ( result , h =>
321
- {
322
- h . AdditionalNewLineAfterOption = false ;
323
- h . Heading = "Myapp 2.0.0-beta" ; //change header
324
- h . Copyright = "Copyright (c) 2019 Global.com" ; //change copyright text
325
- return CommandLine . Text . HelpText . DefaultParsingErrorsHandler ( result , h ) ;
326
- } , e => e ) ;
327
- Console . WriteLine ( helpText ) ;
328
- }
329
-
330
319
private static int UpdateSelfAndRun ( string directory , string [ ] updaterArgs )
331
320
{
332
- string execName = "pocket_updater" ;
333
- string newExecName = "pocket_updater" ;
334
- if ( migrate ) {
335
- newExecName = "pupdate" ;
336
- }
321
+ string execName = "pupdate" ;
337
322
if ( GetPlatform ( ) == "win" ) {
338
323
execName += ".exe" ;
339
- newExecName += ".exe" ;
340
324
}
341
325
string execLocation = Path . Combine ( directory , execName ) ;
342
- string newExecLocation = Path . Combine ( directory , newExecName ) ;
343
326
string backupName = $ "{ execName } .backup";
344
327
string backupLocation = Path . Combine ( directory , backupName ) ;
345
- string updateName = "pocket_updater.zip" ;
346
- if ( migrate ) {
347
- updateName = "pupdate.zip" ;
348
- }
328
+ string updateName = "pupdate.zip" ;
349
329
string updateLocation = Path . Combine ( directory , updateName ) ;
350
330
351
331
int exitcode = int . MinValue ;
@@ -366,8 +346,8 @@ private static int UpdateSelfAndRun(string directory, string[] updaterArgs)
366
346
ZipFile . ExtractToDirectory ( updateLocation , directory , true ) ;
367
347
368
348
// Execute
369
- Console . WriteLine ( $ "Executing { newExecLocation } ") ;
370
- ProcessStartInfo pInfo = new ProcessStartInfo ( newExecLocation ) {
349
+ Console . WriteLine ( $ "Executing { execLocation } ") ;
350
+ ProcessStartInfo pInfo = new ProcessStartInfo ( execLocation ) {
371
351
Arguments = string . Join ( ' ' , updaterArgs ) ,
372
352
UseShellExecute = false
373
353
} ;
@@ -694,21 +674,14 @@ async static Task<bool> CheckVersion(string path)
694
674
List < Github . Release > releases = await GithubApi . GetReleases ( USER , REPOSITORY ) ;
695
675
696
676
string tag_name = releases [ 0 ] . tag_name ;
697
- string releaseUrl = RELEASE_URL ;
698
- string fileName = "pocket_updater" ;
699
- if ( tag_name == "3.0.0" ) {
700
- releaseUrl = NEW_RELEASE_URL ;
701
- fileName = "pupdate" ;
702
- migrate = true ;
703
- }
704
677
string ? v = SemverUtil . FindSemver ( tag_name ) ;
705
678
if ( v != null ) {
706
679
bool check = SemverUtil . SemverCompare ( v , version ) ;
707
680
if ( check ) {
708
681
Console . WriteLine ( "A new version is available. Downloading now..." ) ;
709
682
string platform = GetPlatform ( ) ;
710
- string url = String . Format ( releaseUrl , tag_name , platform ) ;
711
- string saveLocation = Path . Combine ( path , $ " { fileName } .zip") ;
683
+ string url = String . Format ( RELEASE_URL , tag_name , platform ) ;
684
+ string saveLocation = Path . Combine ( path , "pupdate .zip") ;
712
685
await Factory . GetHttpHelper ( ) . DownloadFileAsync ( url , saveLocation ) ;
713
686
Console . WriteLine ( "Download complete." ) ;
714
687
Console . WriteLine ( saveLocation ) ;
@@ -725,7 +698,6 @@ async static Task<bool> CheckVersion(string path)
725
698
}
726
699
}
727
700
728
-
729
701
private static string GetPlatform ( )
730
702
{
731
703
if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ) {
@@ -1008,15 +980,24 @@ __ _ | |
1008
980
| |__| -_| _| |_ -| | | . |_ -| -_| | |
1009
981
|_____|___|_| |___| |_|_|_|___|___|___|_ |
1010
982
|___|" ,
1011
-
1012
-
983
+ @" _=,_
984
+ o_/6 /#\
985
+ \__ |##/
986
+ ='|--\
987
+ / #'-.
988
+ \#|_ _'-. /
989
+ |/ \_( # |''
990
+ C/ ,--___/"
1013
991
} ;
1014
992
}
1015
993
[ Verb ( "menu" , isDefault : true , HelpText = "Interactive Main Menu" ) ]
1016
994
public class MenuOptions
1017
995
{
1018
996
[ Option ( 'p' , "path" , HelpText = "Absolute path to install location" , Required = false ) ]
1019
997
public string ? InstallPath { get ; set ; }
998
+
999
+ [ Option ( 's' , "skip-update" , HelpText = "Skip the self update check" , Required = false ) ]
1000
+ public bool SkipUpdate { get ; set ; }
1020
1001
}
1021
1002
1022
1003
[ Verb ( "update" , HelpText = "Run update all. (You can configure via the settings menu)" ) ]
0 commit comments