Skip to content

Command "emulate" and options "--emulator/--device/--avd" are a bit confusing to use #2349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
pkoleva opened this issue Dec 13, 2016 · 19 comments
Assignees
Milestone

Comments

@pkoleva
Copy link
Contributor

pkoleva commented Dec 13, 2016

emulate command is used to run an app on an emulator but we already have options to specify on what device to run the app.
The different options that one can use to define deployment target are behaving differently
--device - can be used to specify which device to be targeted and accepts device id and device name for some commands -> related issue 2345

run --emulator = emulate, but the option does not accept any parameters - related 2329

If emulate command is removed, to specify which device you'll use, you'll have to type the below command
tns run android/ios --emulator --device {DeviceName/Id}

I think we should agree on some kind of flow that covers the most common use cases.

For me the way I use these options is something like that ->
Option 1 - no emulate command
tns run/debug/deploy/livesync --emulator - starts emulator and ignores all connected real devices
tns run/debug/deploy/livesync --emulator {EmulatorName/Id} - starts/connects to specified emulator or if it doesn't exist give a meaningful error message
'tns run/debug/deploy/livesync --device {EmulatorName/Id}' - starts/connects to specified emulator or if it doesn't exist give a meaningful error message
Option 2 - no --emulator option
tns emulate - starts emulator and runs app on it, ignores all connected real devices
tns emulate --device {DeviceName/Id} - starts emulator with specified name and runs the app on it
'tns run/debug/deploy/livesync --device {EmulatorName/Id}' - starts/connects to specified emulator or if it doesn't exist give a meaningful error message

@enchev
Copy link
Contributor

enchev commented Dec 14, 2016

I like Option 2.

@enchev enchev added the feature label Dec 14, 2016
@tzraikov
Copy link
Contributor

The --avd option is depricated and it is not supported for some time now.
We plan to remove the emulate command (as discussed with @valentinstoychev):
#2329

@pkoleva
Copy link
Contributor Author

pkoleva commented Dec 15, 2016

the option may be deprecated but it is available, as well as --geny option, as @rosen-vladimirov reminded me recently. Also I am not sure removing the command helps a lot - it will still be confusing to use tns run android/ios --emulator --device {DeviceName/Id} for me.

@tzraikov
Copy link
Contributor

It is not necessary to use the --emulator option when using --device.
Currently we fail with an error message when the --avd option is used. I would opt for removing this option.
I was not aware that we have a --geny option. Maybe we should remove it?

@enchev
Copy link
Contributor

enchev commented Dec 15, 2016

I also believe that we should remove --geny & --avd.

@Plamen5kov
Copy link
Contributor

@pkoleva @rosen-vladimirov I vote for removing the emulate command and replace it with
tns run/debug --device "emulator/device name" Which will search for a connected device(emulator or real device) with that name and run on it, or try to start emulator with that name if no such connected device is found.

@toddanglin
Copy link

Before we deprecate the emulate command, we need to make sure the run command works reliably for the emulators.

In 2.5.1, I am still unable to specify a specific iOS device when using the run command. This does not work currently (it reports that the device with that name cannot be found):

$ tns run ios --device "iPad Air 2"

But this command DOES work:

$ tns emulate ios --device "iPad Air 2"

I would expect the first command to behave identically to the second, launching the iOS emulator with the specified device. Further, if we deprecate the emulate command, how would someone launch the emulator with just the default device?

@Plamen5kov
Copy link
Contributor

@toddanglin I was thinking something along the lines of:

Check for --device option:

  • If there isn’t a device option
    • Search for connected devices and run app on all of them or
    • Start default emulator or
    • Throw error unable to connect/start a device
  • If there is a device option
    • Search for device with name specified in --device or
    • Throw error unable to connect to the specified device

@toddanglin
Copy link

There are scenarios where I only want to run my app on the emulators, even if I have a device connected. So if we take this path, I have to explicitly know the name of my emulators...or I have to disconnect all of my devices. There is no direct equivalent for tns emulate to just run on all available emulators. Correct?

Is there a harm in keeping the tns emulate command? Even if not widely promoted?

Meanwhile, for cases where the device name is known, your proposal is fine so long as tns run [platform] --device "[emulator name]" works.

@Plamen5kov
Copy link
Contributor

I have to explicitly know the name of my emulators...

@toddanglin you're right, that's why if you run tns device you'd get all the names of devices and emulators that are currently connected. Of course that doesn't mean we can't keep the emulate command, but IMO we don't need it.


Is there a harm in keeping the tns emulate command? Even if not widely promoted?

There's no harm in keeping the command per se, but the fact is it has caused us trouble in the past. If we have duplicate functionality I see no reason in keeping both ways to do the same thing.

@pkoleva
Copy link
Contributor Author

pkoleva commented Feb 21, 2017

IMO if I have to chose to remove one of "--emulator" or "emulate", I'll choose to remove the first one. I think "--device" option is sufficient to cover the need to run an app on a specific device/emulator/simulator. About "emulate", before removing it we should first define who uses it and how and then find a way to provide the users a way to continue working like they did before.

@toddanglin
Copy link

@pkoleva I agree. I think the tns emulate command is still more intuitive than tns run --emulator

@Plamen5kov My concern is that tns run would require two different behaviors to run the emulator depending on whether you want to explicitly specify the device or not:

tns run [platform] --emulator // Use the default emulator
tns run [platform] --device "Emulator Name" // Use a named emulator

Compared to the consistency of today's command:

tns emulate [platform] // Use the default emulator
tns emulate [platform] --device "Emulator Name" // Use a named emulator

Further, if use I tns run ios (let's say), and I have a device connected, should it fire-up both the emulator and deploy to the device? Are we trying to make tns run do too much?

@pkoleva pkoleva added this to the 3.0.0-RC milestone Feb 27, 2017
@pkoleva
Copy link
Contributor Author

pkoleva commented Mar 1, 2017

Hey all,

We had a discussion and came up with the following ideas. I'll be happy if you share what you think.

We defined 2 main scenarios:

  1. Run your app on all available emulators/simulators
  2. Run your app on a specific emulator/simulator

If we remove tns emulate both scenarios should be covered the following way:

  1. tns run <platform> --emulator - either deploys on all available emulators/simulators or if none are running starts the default one.
  2. tns run <platform> --device <emulatorName/id> - deploys app on the specified emulator/simulator if it's running or starts the emulator/simulator and then deploys

The benefit from using --emulator is actually reusing run command and its default watch behavior. If we all agree on that solution we'll deprecate the command with the release following 3.0.0. In 3.0.0 this command will still be available.

@toddanglin If you don't have connected devices and running emulators tns run <platform> will start your default emulator at our current state - this will not change. You wouldn't need to say tns run <platform> --emulator.

@rosen-vladimirov @Plamen5kov @dtopuzov @vchimev @atanasovg

@toddanglin
Copy link

This approach works fine for me if tns run <platform> --device <emulatorName> is enabled.

What about the other tns emulate flags that are not on tns run? Where will they go? Specifically:

--available-devices
--timeout

I've used both at various times...with iOS to get list of available simulator names and with Android to adjust timeout for slow loading simulator.

@dtopuzov
Copy link
Contributor

dtopuzov commented Mar 7, 2017

Can we also cover the cases when we specify name of emulator image (instead of running android device identifier, like emulator-5554 for example)?

Example:
tns run <platform> --device <name-of-emulator-image>

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Mar 14, 2017

We're going to make the implementation described above by @pkoleva. I'm going to describe all cases we're going to support:

tns run <platform> - if device/emulator/simulator is available: start on all connected and paired devices
tns run <platform> - if device/emulator/simulator is NOT available: start default emulator/simulator
tns run <platform> --emulator - if emulators/simulators are available: start app on all of them
tns run <platform> --emulator - if emulator/simulator is NOT available: start default simulator/emulator
tns run <platform> --device <emulatorName/id> - if emulator/device/simulator with specified id is available: start app on it
tns run <platform> --device <emulatorName/id> - if emulator/simulator/device with specified id is NOT available: tries to start emulator/simulator with given name

EDIT: deprecating the emulate comand.

@toddanglin
Copy link

And again, what about the additional flags available on tns emulate today? Specifically:

  • --available-devices
  • --timeout

Will they work with tns run when the --emulator flag is used?

Critically, I think we should keep tns emulate in the next release in case we have missed other edge cases. It can be deprecated, but given the risk of breaking workflows, it probably should not be removed immediately.

@Plamen5kov
Copy link
Contributor

Plamen5kov commented Mar 15, 2017

@toddanglin --available-devices is already available in tns device android --available-devices, but there's no problem in adding this flag to the run command if it would be more convenient.
and --timeout shouldn't be too difficult to move as a functionality for starting the emulator.

@toddanglin
Copy link

I'm not sure that tns device ios --available-devices does the same thing as tns emulate ios --available-devices.

The first command just lists connected devices (similar to tns devices).

The second command shows a list of ALL valid iOS simulator device names you could use for emulation + any actual connected device names.

That said, I'm okay with moving the functionality of tns emulate ios --available devices to tns device. Let's just make sure they are, in fact, doing the same thing. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants