@@ -25,7 +25,7 @@ const MAX_RECENT_ITEMS = 4
25
25
const SHORTCUT_SEND_URL = `/lab/api/settings/@jupyterlab/shortcuts-extension:shortcuts`
26
26
const USER_AGENT_STR = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36'
27
27
const DRAW_FRAME = true
28
- const VERSION_STRING = '1.0 .0'
28
+ const VERSION_STRING = '1.1 .0'
29
29
30
30
/* Create all the data stores */
31
31
const recentUrlsDb = new RecentUrlsDB ( { name : 'recent_urls' } )
@@ -644,20 +644,76 @@ function addRecentURLListeners () {
644
644
} )
645
645
}
646
646
647
+ function printCLIHeader ( ) {
648
+ console . log ( "Europa " + VERSION_STRING )
649
+ }
650
+
651
+ function printCLIHelp ( args , header , stderr ) {
652
+ let log_obj
653
+
654
+ if ( stderr ) {
655
+ log_obj = console . error
656
+ } else {
657
+ log_obj = console . log
658
+ }
659
+
660
+ if ( header ) {
661
+ printCLIHeader ( )
662
+ log_obj ( "" )
663
+ }
664
+
665
+ log_obj ( "USAGE:\n\t" + args [ 0 ] + " [options]" )
666
+ log_obj ( )
667
+ log_obj ( "OPTIONS:" )
668
+ log_obj ( "\t-u,--url <url> \tOpen a europa window for <url> on start." )
669
+ log_obj ( "\t-v,--version \tPrint version number and exit." )
670
+ log_obj ( "\t-h,--help \tPrint this help message and exit." )
671
+ log_obj ( )
672
+ log_obj ( "OTHER:" )
673
+ log_obj ( "\tCopyright (c) 2020-21 Europa Authors" )
674
+ log_obj ( "\tReport bugs at: https://europa.suyashmahar.com/report-bugs" )
675
+ }
676
+
677
+ function printCLIVersion ( ) {
678
+ printCLIHeader ( ) ;
679
+ }
680
+
647
681
/**
648
682
* Parse command line arguments
649
683
*/
650
684
function parseCmdlineArgs ( ) {
651
685
let args = process . argv
652
- console . log ( args )
653
-
654
- for ( let i = 0 ; i < args . length ; i ++ ) {
655
-
686
+ let result = { 'url' : '' }
687
+
688
+ for ( let i = 1 ; i < args . length ; i ++ ) {
689
+ if ( args [ i ] == "--help" || args [ i ] == "-h" ) {
690
+ printCLIHelp ( args , true )
691
+ app . exit ( 0 )
692
+ } else if ( args [ i ] == "--version" || args [ i ] == "-v" ) {
693
+ printCLIVersion ( )
694
+ app . exit ( 0 )
695
+ } else if ( args [ i ] == "--url" || args [ i ] == "-u" ) {
696
+ if ( args . length < i + 2 ) {
697
+ console . error ( "--url requires exactly one argument" )
698
+ console . error ( )
699
+ printCLIHelp ( args , false , true )
700
+ }
701
+
702
+ result [ 'url' ] = args [ i + 1 ]
703
+ i += 1
704
+ } else {
705
+ console . error ( "Unknown argument '" + args [ i ] + "'" )
706
+ console . error ( )
707
+ printCLIHelp ( args , false , true )
708
+ app . exit ( 1 )
709
+ }
656
710
}
711
+
712
+ return result
657
713
}
658
714
659
715
function main ( ) {
660
- parseCmdlineArgs ( )
716
+ let args = parseCmdlineArgs ( )
661
717
662
718
fixASARPath ( )
663
719
@@ -691,6 +747,10 @@ function main () {
691
747
ipcMain . on ( 'open-url' , showEuropaBrowser )
692
748
ipcMain . on ( 'show-about-europa' , e => showAboutDialog ( e . sender ) )
693
749
ipcMain . on ( 'dialog-result' , ( event , id , resp ) => dialogRespTracker [ id ] ( resp ) )
750
+
751
+ if ( args [ 'url' ] != "" ) {
752
+ showEuropaBrowser ( null , args . url )
753
+ }
694
754
}
695
755
696
756
app . on ( 'ready' , main )
0 commit comments