src/Procedure/ProcedureValidator.php
private function checkPermissions($style)
    {
        $warnings = [];

        foreach($this->procedure->getCommands() as $command) {

            /* Skip evalutating commands that do not recommend root */
            if(! $command->hasPublicMethod('recommendsRoot')) continue;

            if($command->recommendsRoot() && ! ShellUser::getInstance()->isRoot()) {
                $name = $command->getName();
                $user = ShellUser::getInstance()->getName();
                $warnings[] = "Command $name recommends running as root, currently $user.";
            }
        }

        if(!empty($warnings)) {
            $style->warning($warnings);
            if($style->confirm("Would you like to abort current procedure ({$this->procedure->getName()})?")) {
                $this->abort("Procedure aborted by user");
            }
        }
    }
private function checkPermissions($style)
    {
        $warnings = [];

        foreach($this->procedure->getCommands() as $command) {

            /* Skip evalutating commands that do not recommend root */
            if(! $command->hasPublicMethod('recommendsRoot')) continue;

            if($command->recommendsRoot() && ! ShellUser::getInstance()->isRoot()) {
                $name = $command->getName();
                $user = ShellUser::getInstance()->getName();
                $warnings[] = "Command $name recommends running as root, currently $user.";
            }
        }

        if(!empty($warnings)) {
            $style->warning($warnings);
            if($style->confirm("Would you like to abort current procedure ({$this->procedure->getName()})?")) {
                $this->abort("Procedure aborted by user");
            }
        }
    }
private function checkPermissions ( $ style ) { $ warnings = [ ] ; foreach ( $ this -> procedure -> getCommands ( ) as $ command ) { /* Skip evalutating commands that do not recommend root */ if ( ! $ command -> hasPublicMethod ( 'recommendsRoot' ) ) continue ; if ( $ command -> recommendsRoot ( ) && ! ShellUser :: getInstance ( ) -> isRoot ( ) ) { $ name = $ command -> getName ( ) ; $ user = ShellUser :: getInstance ( ) -> getName ( ) ; $ warnings [ ] = "Command $name recommends running as root, currently $user." ; } } if ( ! empty ( $ warnings ) ) { $ style -> warning ( $ warnings ) ; if ( $ style -> confirm ( "Would you like to abort current procedure ({$this->procedure->getName()})?" ) ) { $ this -> abort ( "Procedure aborted by user" ) ; } } }
Warn user if procedure should be ran as root and is being ran by some other user
Warn user if procedure should be ran as root and is being ran by some other user