Merge branch 'develop' into spike/JAL-4047/JAL-4048_columns_in_sequenceID
[jalview.git] / utils / getdown / bin / jalview.ps1
index 7ae9a57..1098010 100755 (executable)
@@ -57,12 +57,6 @@ $CMDPATH = ( Get-Item $MyInvocation.MyCommand.Path )
 $SCRIPTPATH = Readlink-f -Link $CMDPATH
 $DIR = Split-Path -Path $SCRIPTPATH -Parent
 
-# set the "-open" parameter if myArg1 is non-zero-length, and not "open" or starts with a "-"
-$OPEN = ""
-if ( $myArg1.length -gt 0 -and ( -not $myArg1.StartsWith("-") ) -and $myArg1 -cne "open" ) {
-  $OPEN = "-open"
-}
-
 $APPDIR = If ( ( Split-Path -Path $DIR -Leaf ) -eq "bin" ) { Split-Path -Path $DIR -Parent } Else { $DIR }
 $JAVAEXE = If ( $myIsWindows ) { "java.exe" } Else { "java" }
 $JAVA = Join-Path -Path $APPDIR -ChildPath ( "jre/" + $( If ( $myIsMacOS ) { "Contents/Home/" } Else { "" } ) + "bin/${JAVAEXE}" )
@@ -81,7 +75,14 @@ if ( -not ( Test-Path -Path "${JAVA}" ) ) {
 
 $CLASSPATH = ( Select-String -Path "${GETDOWNTXT}" -AllMatches -Pattern "code\s*=\s*(.*)$" | foreach { Join-Path -Path $APPDIR -ChildPath $($_.Matches.Groups[1].Value ) } ) -join $( If ( $myIsWindows ) { ";" } Else { ":" } )
 
+# get console width
+$CONSOLEWIDTH = $Host.UI.RawUI.WindowSize.Width
+
 # quote the args and the command (in case of spaces) with escape chars (`) and precede with & to indicate command not string
-$myArgsString = '"' + $($myArgs -join '" "') + '"'
-Invoke-Expression -Command "& `"${JAVA}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${OPEN} ${myArgsString}"
+if ( $myArgs.count -eq 0 ) {
+  Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" `"-Dgetdownappdir=${APPDIR}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher"
+} else {
+  $myArgsString = '"' + $($myArgs -join '" "') + '"'
+  Invoke-Expression -Command "& `"${JAVA}`" `"-DCONSOLEWIDTH=${CONSOLEWIDTH}`" `"-Dgetdownappdir=${APPDIR}`" -cp `"${CLASSPATH}`" jalview.bin.Launcher ${myArgsString}"
+}