core/src/main/java/eu/darken/rxshell/cmd/Cmd.java
/**
         * This is a convenience method for single-shot execution.
         * <p>It's behavior depends on {@link RxCmdShell#isAlive()}.
         * <br>If the shell is alive, then the existing session is used and kept open.
         * <br>If the shell wasn't alive, a new session is created and closed after the command has terminated.
         *
         * @param shell the {@link RxCmdShell} to use.
         * @return a {@link Single} that will emit a {@link Cmd.Result} when the command has terminated.
         */
This is a convenience method for single-shot execution.
It's behavior depends on  RxCmdShell#isAlive().
If the shell is alive, then the existing session is used and kept open.
If the shell wasn't alive, a new session is created and closed after the command has terminated.

@param shell the  RxCmdShell to use.
@return a  Single that will emit a  Cmd.Result when the command has terminated.
This is a convenience method for single - shot execution . It ' s behavior depends on RxCmdShell#isAlive () . If the shell is alive then the existing session is used and kept open . If the shell wasn ' t alive a new session is created and closed after the command has terminated . @param shell the RxCmdShell to use . @return a Single that will emit a Cmd . Result when the command has terminated .
public Single<Result> submit(RxCmdShell shell) {
            final Cmd cmd = build();
            return shell.isAlive().flatMap(wasAlive ->
                    shell.open().flatMap(session ->
                            session.submit(cmd).flatMap(result -> {
                                if (!wasAlive) return session.close().map(integer -> result);
                                else return Single.just(result);
                            })));
        }
public Single < Result > submit ( RxCmdShell shell ) { final Cmd cmd = build ( ) ; return shell . isAlive ( ) . flatMap ( wasAlive -> shell . open ( ) . flatMap ( session -> session . submit ( cmd ) . flatMap ( result -> { if ( ! wasAlive ) return session . close ( ) . map ( integer -> result ) ; else return Single . just ( result ) ; } ) ) ) ; }
This is a convenience method for single-shot execution.
This is a convenience method for single - shot execution .