Electron Windows Production Bundle Command Line Arguments - windows

I'm building an Electron App using electron-builder on macOS.
In my code I access the command line args like this:
const cmd = electron.remote.app.commandLine;
const val = cmd.hasSwitch('myArg')
? cmd.getSwitchValue('myArg')
: undefined;
This works fine for the production build on macOS when providing the arguments:
./my-electron-app.app/Contents/MacOS/my-electron-app --myArg=foo
// or:
open my-electron-app.app --args -myArg=foo
But on Windows I can't get it working.
Here's what I tried using cmd.exe:
my-electron-app.exe --myArg=foo
my-electron-app.exe -myArg=foo
my-electron-app.exe /myArg=foo
my-electron-app.exe myArg=foo
When logging electron.remote.process.argv[1] I can see the passed arguments on macOS and Windows, but hasSwitch and getSwitchValue won't give me the value.
What am I doing wrong? Or is there a better way to get cross platform command line arguments working?

I'm gonna take a guess that this is because of the capital letters in your switch. See this closed issue:
This is intentional. The hasSwitch API is a direct wrapper of the Chromium CommandLine class, which behaves this way on purpose.
From Chromium source:
Switch names must be lowercase.
Though it's not totally clear to me yet why Mac doesn't suffer from the same problem.

Related

MacOS VulkanInfo Reports 0 Validation Layers

I am getting started with Vulkan (vulkansdk-macos-1.1.126.0) on macOS (10.14.6), and have followed a tutorial in setting up an instance which all seems to go well however when I call vkEnumerateInstanceLayerProperties I get a returned layer count of 0.
At first I thought it could be my build arguments/variables, however when I run the vulkanInfo application supplied with the tar.gz it also reports there that there are no layers (Layers: count = 0). I then tried to add environment variables:
PATH=$PATH:$VULKAN_ROOT/bin
export VK_LAYER_PATH=$VULKAN_ROOT/etc/vulkan/explicit_layers.d
export VK_ICD_FILENAMES=$VULKAN_ROOT/etc/vulkan/icd.d/MoltenVK_icd.json
export VK_LAYER_PATH=$VULKAN_ROOT/etc/vulkan/explicit_layers.d
export VK_INSTANCE_LAYERS=VK_LAYER_LUNARG_standard_validation vulkaninfo
#export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation vulkaninfo
and launch vulkanInfo from the terminal. Maybe it is a Mac trying to be too secure issue or has something to do with file permissions. Any suggestions are appreciated since this will seriously hamper debugging.
So as you'd expect I was doing something wrong, just doing 2 different things wrong:
- for launching vulkanInfo from the terminal, you can see that I wasn't exporting the PATH variable.
- for VSCode (where I am building the application) I had the VK_ICD_FILENAMES and VK_LAYER_PATH as preprocessor definitions, not as launch environment variables (set in the launch.json, environment name/value map).

How to display command history with jline3?

I want the most recent command entered to be displayed when the user presses the up arrow key.
The Terminal is defined like this (Scala code):
val terminal: Terminal =
TerminalBuilder.builder
.system(true)
.build
The LineReader is defined like this:
def reader(parser: Parser, terminal: Terminal): LineReader = {
val lineReader: LineReader = LineReaderBuilder.builder
.terminal(terminal)
.completer(shellManager.topShell.completer)
.parser(parser)
.variable(LineReader.HISTORY_FILE, historyFile)
.history(new DefaultHistory())
.build
lineReader.unsetOpt(LineReader.Option.INSERT_TAB)
lineReader
}
Update: I found that the above actually works on some consoles, not others. I am still discovering what works and what does not. Any insight would be appreciated.
This is supposed to work out-of-the box. If you have an issue with a specific terminal, please report which exact terminal you use. For what it's worth, this can't work from inside build tools (gradle, maven) or IDE (Eclipse, Intellij IDEA).

Open HTML in chrome from command line using app flag

(Before downvote im aware how to do this using code thats inline to this command but not how to do it using a file that uses the --app="data:text/html,<sometags></sometags>)
How would I open a local html (mar.html) file using this command
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app=
Specifically, the issue is my lack of familiarity with the --app flag
I tried
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app="mar.html"
C:\'Program Files (x86)'\Google\Chrome\Application\chrome.exe --profile-directory="Default" --app="file:///mar.html"
Both don't work.
Giving me the error
Your file was not found
It may have been moved or deleted.
ERR_FILE_NOT_FOUND
You almost got it. The file descriptor path must be absolute and encoded.
Encoding the path correctly with cli tools like "urlencode"(gridsite-clients) did not work for me.
If you have NodeJS installed and would use a linux machine, you could use this command.
chromium --app=`node -e "console.log('file://'+encodeURI(process.argv[1]))" "$(realpath "/path/of/your/file.html")"`
This works also fine with relative paths.
For windows you have to rewrite this yourself.

Running a command line for groovy from XCode after unit testing

I edited my target scheme to run a script action after testing as below
Target Scheme -> Test (Debug) -> Post Actions
The script hw.sh had a simple command line call:
open /Applications/Safari.app/
It worked fine for the above script. When I changed it to the following
groovy http://frankencover.it/with -s /Users/sasokan/Downloads/MyProject
Nothing happened. How can I call this groovy application using a script.
I am also trying to run frankencover.it and had the same problem you did. I eventually found this answer on SO that lead me to a solution. I added the following before calling frankencover.it and it fixed the issue.
PATH=${PATH}:/usr/local/bin
I will further note that even if you use the full path to groovy in the command frankencover.it will fail internally because it cannot find 'lcov' for the same reason.

Running casperjs tests with slimerjs

I wrote a few tests with casperjs. They run just fine with phantomjs. However, when I tried to use slimerjs with the following command:
casperjs --verbose --engine=slimerjs test create-project-suite.js
A small window appers with the SlimerJs logo and version number but the console seems to hang with the following line:
Test file: create-project-suite.js
Is there anything else I need to do? Here are the version numbers:
Mozilla Firefox 28.0
CasperJS version 1.1.0-beta3
Innophi SlimerJS 0.9.1
3.8.0-37-generic #53~precise1-Ubuntu
Update:
I removed code until I got slimerjs to open the browser and execute tests. It seems that it hangs whenever I require a js file (I'm following the page objects pattern):
var Login = require('./objects/login');
I think require.paths could be helpful. Any ideas on how to get around this?
Using full paths makes slimerjs happy:
var path = fs.absolute(fs.workingDirectory + '/objects/login');
var Login = require(path);
It is plain simpler to move all modules to the same directory where the script is.
I tried your command and it works for me, maybe in your file you use an instruction specific to phantom :
http://docs.slimerjs.org/0.8/differences-with-phantomjs.html
But it should open the window(at least the start() ).
Anyway the command is fine.

Resources