- From a command prompt, run the ODT executable in packager mode with a reference to the configuration file you saved and to the location where you want to save the App-V package. In the following example, the configuration file is named packageconfig.xml and the App-V package will be saved to server share appv.
- If you spend a decent amount of time with the command line though, it’s nice to be able to launch Mac apps directly from there as well. Also, the Terminal has a fair share of applications that run in text based mode, but maybe you wanted to edit a text file in the OS X GUI app TextWrangler rather than the text based nano or vim.
- Recently I've been wanting a way to pass command-line arguments to GUI apps by default, in my case a -geometry parameter to Emacs.app to make it start up in something approximating full-screen mode. It turns out there's a very easy way to do this.
- You may find it easier to add the cypress command to the scripts object in your package.json file and call it from an npm run script. When calling a command using npm run, you need to pass the command's arguments using the -string. For example, if you have the following command defined in your package.json.
Mac Run App From Command Line With Arguments Free
On run argv set product to item 1 of argv tell application 'Terminal' activate do script product end tell end run This AppleScript opens Terminal.app and runs the first command-line argument inside Terminal.app.
This guide shows you how to create applications and deploy them tovarious native mobile platforms using the cordova
command-lineinterface (CLI). This tool allows you to create new projects, buildthem on different platforms, and run on real devices or withinemulators. The CLI is the main tool to use for the cross-platformworkflow described in the Overview. Otherwise you can also use theCLI to initialize project code, then switch to various platforms' SDKsand shell tools for continued development.
Prerequisites
Before running any command-line tools, you need to install SDKs foreach platform you wish to target.(See the Platform Guides for more details.)
To add support or rebuild a project for any platform, you need to runthe command-line interface from the same machine that supports theplatform's SDK. The CLI supports the following combinations:
- iOS (Mac)
- Amazon Fire OS (Mac, Linux, Windows)
- Android (Mac, Linux, Windows)
- BlackBerry 10 (Mac, Linux, Windows)
- Windows Phone 8 (Windows)
- Windows (Windows)
- Firefox OS (Mac, Linux, Windows)
On the Mac, the command-line is available via the Terminalapplication. On the PC, it's available as Command Prompt underAccessories.
NOTE: For Windows-only platforms, you can still do yourdevelopment on Mac hardware by running Windows in a virtual machineenvironment or in dual-boot mode. For available options, see theWindows Phone 8 Platform Guide or the Windows Platform Guide.
The more likely it is that you run the CLI from different machines,the more it makes sense to maintain a remote source code repository,whose assets you pull down to local working directories.
Installing the Cordova CLI
The Cordova command-line tool is distributed as an npm package in aready-to-use format. It is not necessary to compile it from source.
To install the cordova
command-line tool, follow these steps:
Download and install Node.js. Followinginstallation, you should be able to invoke
node
andnpm
on yourcommand line. If desired, you may optionally use a tool such asnvm
ornave
to manage your Node.js installation.Download and install a git client, if you don'talready have one. Following installation, you should be able to invoke
git
on your command line. Even though you won't be usinggit
manually,the CLI does use it behind-the-scenes to download some assets whencreating a new project.Install the
cordova
module usingnpm
utility of Node.js. Thecordova
module will automatically be downloaded by thenpm
utility.
on OS X and Linux:
On OS X and Linux, prefixing the
npm
command withsudo
may be necessary to install this development utility in otherwise restricted directories such as/usr/local/share
. If you are using the optional nvm/nave tool or have write access to the install directory, you may be able to omit thesudo
prefix. There are more tips available on usingnpm
withoutsudo
, if you desire to do that.on Windows:
The -g
flag above tells npm
to install cordova
globally. Otherwise it will be installed in the node_modules
subdirectory of the current working directory.
You may need to add the npm
directory to your PATH
in order to invoke globally installed npm
modules. On Windows, npm
can usually be found at C:UsersusernameAppDataRoamingnpm
. On OS X and Linux it can usually be found at /usr/local/share/npm
.
The installation log may produce errors for any uninstalled platform SDKs.
Following installation, you should be able to run cordova
on the command line with no arguments and it should print help text.
Create the App
Go to the directory where you maintain your source code, and run acommand such as the following:
It may take some time for the command to complete, so be patient. Runningthe command with the -d
option displays information about its progress.
The first argument hello specifies a directory to be generatedfor your project. This directory should not already exist, Cordova willcreate it for you. Its www
subdirectory houses your application'shome page, along with various resources under css
, js
, and img
,which follow common web development file-naming conventions. These assetswill be stored on the device's local filesystem, not served remotely. Theconfig.xml
file contains important metadata needed to generate anddistribute the application.
The second argument com.example.hello
provides your project with a reverse domain-style identifier. This argumentis optional, but only if you also omit the third argument, since the argumentsare positional. You can editthis value later in the config.xml
file, but do be aware that there maybe code generated outside of config.xml
using this value, such as Javapackage names. The default value is io.cordova.hellocordova
, but it isrecommended that you select an appropriate value.
The third argument HelloWorld
provides the application's display title.This argument is optional. You can edit this value later in the config.xml
file, but do be aware that there may be code generated outside of config.xml
using this value, such as Java class names. The default value is HelloCordova
,but it is recommended that you select an appropriate value.
Add Platforms
All subsequent commands need to be run within the project's directory,or any subdirectories within its scope:
Before you can build the project, you need to specify a set of targetplatforms. Your ability to run these commands depends on whether yourmachine supports each SDK, and whether you have already installed eachSDK. Run any of these from a Mac:
Run any of these from a Windows machine, where wp refers todifferent versions of the Windows Phone operating system:
Mac Run App From Command Line With Arguments Mac
Run this to check your current set of platforms:
(Note the platform
and platforms
commands are synonymous.)
Run either of the following synonymous commands to remove a platform:
Running commands to add or remove platforms affects the contents ofthe project's platforms directory, where each specified platformappears as a subdirectory. The www source directory is reproducedwithin each platform's subdirectory, appearing for example inplatforms/ios/www
or platforms/android/assets/www
. Because the CLIconstantly copies over files from the source www folder, you should onlyedit these files and not the ones located under the platforms subdirectories.If you use version control software, you should add this source www folder, along with the merges folder, to your version control system. (More informationabout the merges folder can be found in the Customize Each Platform section below.)
WARNING: When using the CLI to build your application, you shouldnot edit any files in the /platforms/
directory unless you knowwhat you are doing, or if documentation specifies otherwise. The filesin this directory are routinely overwritten when preparingapplications for building, or when plugins are reinstalled.
If you wish at this point, you can use an SDK such as Eclipse or Xcodeto open the project you created. You will need to open the derivative set of assetsfrom the /platforms/
directory to develop with an SDK. This is becausethe SDK specific metadata files are stored within the appropriate /platform/
subdirectory.(See the Platform Guides for information on how to develop applications within each IDE.)Use this approach if you simply want to initialize a project using the CLI and then switch to an SDK for native work.
Read on if you wish to use the cross-platform workflow approach (the CLI) for the entiredevelopment cycle.
Build the App
By default, the cordova create
script generates a skeletal web-basedapplication whose home page is the project's www/index.html
file.Edit this application however you want, but any initialization shouldbe specified as part of the [deviceready](././cordova/events/events.deviceready.html)
event handler, referenced bydefault from www/js/index.js
.
Run the following command to iteratively build the project:
This generates platform-specific code within the project's platforms
subdirectory. You can optionally limit the scope of each build tospecific platforms:
The cordova build
command is a shorthand for the following, which inthis example is also targeted to a single platform:
In this case, once you run prepare
, you can use Apple's Xcode SDK asan alternative to modify and compile the platform-specific code thatCordova generates within platforms/ios
. You can use the sameapproach with other platforms' SDKs.
Test the App on an Emulator or Device
SDKs for mobile platforms often come bundled with emulators thatexecute a device image, so that you can launch the app from the homescreen and see how it interacts with many platform features. Run acommand such as the following to rebuild the app and view it within aspecific platform's emulator:
Some mobile platforms emulate a particular device by default, such asthe iPhone for iOS projects. For other platforms, you may need tofirst associate a device with an emulator.
NOTE: Emulator support is currently not available for Amazon Fire OS.
(See the Platform Guides for details.)For example, you may first run the android
command to launch theAndroid SDK, then run a particular device image, which launches itaccording to its default behavior:
Following up with the cordova emulate
command refreshes the emulatorimage to display the latest application, which is now available forlaunch from the home screen:
Alternately, you can plug the handset into your computer and test theapp directly:
Before running this command, you need to set up the device fortesting, following procedures that vary for each platform. InAndroid and Amazon Fire OS devices, you would have to enable a USB debugging option onthe device, and perhaps add a USB driver depending on your developmentenvironmnent.See Platform Guides for details on each platform's requirements.
Add Plugin Features
When you build and view a new project, the default application thatappears doesn't do very much. You can modify the app in many ways totake advantage of standard web technologies, but for the app tocommunicate closely with various device-level features, you need toadd plugins that provide access to core Cordova APIs.
A plugin is a bit of add-on code that provides an interface tonative components. You can design your own plugin interface, forexample when designing a hybrid app that mixes a Cordova WebView withnative components. (See Embedding WebViews and Plugin DevelopmentGuide for details.) More commonly, you would add a plugin to enableone of Cordova's basic device-level featuresdetailed in the API Reference.
As of version 3.0, when you create a Cordova project it does not have anyplugins present. This is the new default behavior. Any plugins you desire,even the core plugins, must be explicitly added.
A list of these plugins, includingadditional third-party plugins provided by the community, can be foundin the registry atplugins.cordova.io. You can usethe CLI to search for plugins from this registry. For example,searching for bar
and code
produces a single result that matchesboth terms as case-insensitive substrings:
Searching for only the bar
term yields and additional result:
The cordova plugin add
command requires you to specify therepository for the plugin code. Here are examples of how you mightuse the CLI to add features to the app:
Basic device information (Device API):
Network Connection and Battery Events:
Accelerometer, Compass, and Geolocation:
Camera, Media playback and Capture:
Access files on device or network (File API):
Notification via dialog box or vibration:
Contacts:
Globalization:
Splashscreen:
Open new browser windows (InAppBrowser):
Debug console:
NOTE: The CLI adds plugin code as appropriate for each platform.If you want to develop with lower-level shell tools or platform SDKsas discussed in the Overview, you need to run the Plugman utility toadd plugins separately for each platform. (For more information, seeUsing Plugman to Manage Plugins.)
Use plugin ls
(or plugin list
, or plugin
by itself) to viewcurrently installed plugins. Each displays by its identifier:
To remove a plugin, refer to it by the same identifier that appears inthe listing. For example, here is how you would remove support for adebug console from a release version:
You can batch-remove or add plugins by specifying more than oneargument for each command:
Advanced Plugin Options
When adding a plugin, several options allow you to specify from whereto fetch the plugin. The examples above use a well-knownregistry.cordova.io
registry, and the plugin is specified by theid
:
The id
may also include the plugin's version number, appended afteran @
character. The latest
version is an alias for the most recentversion. For example:
If the plugin is not registered at registry.cordova.io
but is located inanother git repository, you can specify an alternate URL:
The git example above fetches the plugin from the end of the masterbranch, but an alternate git-ref such as a tag or branch can beappended after a #
character:
If the plugin (and its plugin.xml
file) is in a subdirectory withinthe git repo, you can specify it with a :
character. Note that the#
character is still needed:
You can also combine both the git-ref and the subdirectory:
Alternately, specify a local path to the plugin directory thatcontains the plugin.xml
file:
Using merges to Customize Each Platform
While Cordova allows you to easily deploy an app for many differentplatforms, sometimes you need to add customizations. In that case,you don't want to modify the source files in various www
directorieswithin the top-level platforms
directory, because they're regularlyreplaced with the top-level www
directory's cross-platform source.
Instead, the top-level merges
directory offers a place to specifyassets to deploy on specific platforms. Each platform-specificsubdirectory within merges
mirrors the directory structure of thewww
source tree, allowing you to override or add files as needed.For example, here is how you might uses merges
to boost the defaultfont size for Android and Amazon Fire OS devices:
Edit the
www/index.html
file, adding a link to an additional CSSfile,overrides.css
in this case:Optionally create an empty
www/css/overrides.css
file, which wouldapply for all non-Android builds, preventing a missing-file error.Create a
css
subdirectory withinmerges/android
, then add acorrespondingoverrides.css
file. Specify CSS that overrides the12-point default font size specified withinwww/css/index.css
, forexample:
When you rebuild the project, the Android version features the customfont size, while others remain unchanged.
You can also use merges
to add files not present in the originalwww
directory. For example, an app can incorporate a back buttongraphic into the iOS interface, stored inmerges/ios/img/back_button.png
, while the Android version caninstead capture [backbutton](././cordova/events/events.backbutton.html)
events from the corresponding hardwarebutton.
Help Commands
Cordova features a couple of global commands, which may help you ifyou get stuck or experience a problem. The help
command displaysall available Cordova commands and their syntax:
Additionally, you can get more detailed help on a specific command.For example:
The info
command produces a listing of potentially useful details,such as currently installed platforms and plugins, SDK versions foreach platform, and versions of the CLI and node.js
:
It both presents the information to screen and captures the output ina local info.txt
file.
NOTE: Currently, only details on iOS and Android platforms areavailable.
Updating Cordova and Your Project
After installing the cordova
utility, you can always update it tothe latest version by running the following command:
Use this syntax to install a specific version:
Run cordova -v
to see which version is currently running. Run the npminfo
command for a longer listing that includes the current versionalong with other available version numbers:
Cordova 3.0 is the first version to support the command-line interfacedescribed in this section. If you are updating from a version prior to3.0, you need to create a new project as described above, then copythe older application's assets into the top-level www
directory.Where applicable, further details about upgrading to 3.0 are availablein the Platform Guides. Once you upgrade to the cordova
command-line interface and use npm update
to stay current, the moretime-consuming procedures described there are no longer relevant.
Cordova 3.0+ may still require various changes toproject-level directory structures and other dependencies. After yourun the npm
command above to update Cordova itself, you may need toensure your project's resources conform to the latest version'srequirements. Run a command such as the following for each platformyou're building:
Use PhpStorm features from the command line: open files and projects, view diffs, merge files, apply code style formatting, and inspect the source code.
For information about running command-line tools from inside PhpStorm, see Terminal.
Launcher for a standalone instance
The installation directory contains batch scripts and executables for launching PhpStorm, formatting the source code, and running inspections. To use them from the Command Prompt cmd.exe, add the location of the PhpStorm bin folder to the PATH
environment variable. For example, if you installed PhpStorm to C:Program FilesJetBrainsPhpStorm, you can use the following command:
This command changes the PATH
environment variable for the current shell only (the current instance of cmd.exe ). If you want to update it permanently for the current user, run setx
. To update it system-wide for all users, run setx /M
.
The installer can do this for you if you select Add launchers dir to the PATH on the Installation Options step of the setup wizard.
After you configure the PATH
variable, you can run the corresponding executable from any working directory in the Command Prompt: phpstorm64.exe
for 64-bit versions or phpstorm.exe
for 32-bit versions. Alternatively, you can use the batch script: phpstorm.bat
.
To run PhpStorm from the shell, use the open
command with the following options:
-a
: specify the application.--args
: specify additional arguments when passing more than just the file or directory to open.-n
: open a new instance of the application even if one is already running.
For example, you can run PhpStorm.app with the following command: Lfs clock serial number.
If PhpStorm is not in the default /Applications directory, specify the full path to it.
You can create a shell script with this command in a directory from your PATH
environment variable. For example, create the file /usr/local/bin/phpstorm with the following contents:
Make sure you have permissions to execute the script and since /usr/local/bin should be in the PATH
environment variable by default, you should be able to run phpstorm
from anywhere in the shell.
On Linux, the installation directory contains the launcher shell script phpstorm.sh under bin. For example, if you installed PhpStorm to /opt/phpstorm, you can run the script using the following command:
You can create a symbolic link to the launcher script in a directory from the PATH
environment variable. For example, if you installed PhpStorm to /opt/phpstorm and want to create a link named phpstorm in /usr/local/bin, run the following command:
Since /usr/local/bin should be in the PATH
environment variable by default, you should be able to run the phpstorm
command from anywhere in the shell.
Shell scripts generated by the Toolbox App
If you are using the Toolbox App to install and manage JetBrains products, it can create shell scripts for launching your IDEs from the command line.
Generate shell scripts
Open the Toolbox App and click in the top right corner.
In the Toolbox App Settings, enable Generate shell scripts.
If necessary, change the shell scripts location.
If you have several versions of the same IDE, the Toolbox App generates a shell script for each version with a unique name. You can change the name of the shell script for an IDE instance in the settings for this specific instance.
Change the name of the shell script
Open the Toolbox App.
Click next to the relevant IDE instance and select Settings.
At the bottom, change the Shell script name field.
By default, the Toolbox App puts shell scripts in a directory from the system PATH
environment variable, so you can run the name of the script as a command to launch PhpStorm from any working directory.
Command-line arguments
The launcher script accepts commands, options, and other arguments to modify its behavior:
Argument | Description |
---|---|
No argument | Launch PhpStorm. |
Path to file or directory | Open the file or directory specified as the argument. For more information, see Open files from the command line. |
Commands | |
diff | Open the diff viewer to see differences between two specified files. For more information, see Compare files from the command line. |
merge | Open the Merge dialog to merge the specified files. For more information, see Merge files from the command line. |
format | Apply code style formatting to the specified files. For more information, see Format files from the command line. |
inspect | Perform code inspection on the specified project. For more information, see Run code inspections from the command line. |
Options | |
nosplash | Do not show the splash screen when loading PhpStorm. |
dontReopenProjects | Do not reopen projects and show the welcome screen. This can help if a project that was open crashes PhpStorm for some reason. |
disableNonBundledPlugins | Do not load manually installed plugins. This can help if a plugin that you installed crashes PhpStorm for some reason. You will be able to start the IDE and either disable or uninstall the problematic plugin. |
--wait | Wait for the files to be closed before returning to the command prompt. |