Command-line options
Other file managers usually accept command-line options. For example, you can specify a folder when launching Windows Explorer. It also responds to various switches. Let's say that you can give it switch /e
, and Explorer will open the folder in expanded mode.
NW.js
reveals command-line options as an array of strings in nw.App.argv
. So, we can change the code of the DirService
initialization in the main module:
./js/app.js
const dirService = new DirService( nw.App.argv[ 0 ] );
Now, we can open a specified folder in the File Explorer straight from the command line:
npm start ~/Sandbox
In UNIX-based systems, the tilde means user home directory. The equivalent in Windows will be as follows:
npm start %USERPROFILE%Sandbox
What else can we do? Just for a showcase, I suggest implementing the --minimize
and --maximize
options that switch the application window mode on startup, respectively: ./js/app.js
const argv = require( "minimist" )( nw.App.argv ), dirService = new DirService...