Ferreteria/v0.6/clade/App

From Woozle Writes Code
< Ferreteria‎ | v0.6‎ | clade
Jump to navigation Jump to search
Clade Family
(root) App Routed
Clade Aliases
Alias Clade
Single* [i,t] Aux\Singleton
Base* [c,i] Aux\StandardBase
Subpages

About

Dispatch Functions

  1. ReadAppConfig(): make sure always-used configuration details are loaded
  2. ShowAppConfig(): displays info about the app based on its configuration (not affected by user input)
    • In CLI apps, this shows name/version/etc.
    • In web apps, this might be a header which is common to all pages.
  3. ReadUserCommand(): reads/interprets command-line or URI
  4. DescribeActions(): describe what is going to happen when the command is executed
    • In CLI apps (its main usage), this describes what the app is going to try to do.
    • In web apps, this might render subheader details regarding how the URI is being interpreted.
  5. ExecuteActions(): execute the command and display results

Pages

History

  • 2024-01-04 As part of reorganizing the startup process, I'm changing App (back?) to dynamic so we can put the instantiated version in Globals.
  • 2024-11-14 reorganized some stuff in Go(), because things were getting called twice.
    • renamed EmitStartup() -> SetupIface()
  • 2025-03-05 renamed SetupIface() -> PreInputSetup()
  • 2025-03-07 more renaming:
    • PreInputSetup() -> ReadAppConfig()
    • InterpretInput() -> ReadUserCommand()
    • RenderIface() -> DescribeActions()
    • ExecuteInput() -> ExecuteActions()
    • adding ShowAppConfig()

Code

as of 2025-10-18

interface iApp extends BaseIface, SingleIface {
    function Go();
}
abstract class caApp extends BaseClass implements iApp {
    use SingleTrait;

    // ++ ACTION ++ //

    public function Go() {
        global $nfErr;

        $this->GoDirectly();
        #$this->GoWithCatch();
    }
    protected function GoDirectly() {
        $this->TryIt();
    }
    // NOTE 2025-03-05 HandleThrown() is not currently implemented for CLI. Adapt from Web version if needed.
    protected function GoWithCatch() {
        try {
            $this->TryIt();
        } catch(Error $e) {
            $this->HandleThrown($e);
        } catch(Exception $e) {
            $this->HandleThrown($e);
        } catch(Throwable $e) {
            $this->HandleThrown($e);
        } finally {
            #echo '<br>Resuming execution...<br>';
        }
    }
    protected function TryIt() {
        $this->AmHere('ReadAppConfig()');
        $this->ReadAppConfig();     // read the app's configuration
        $this->AmHere('ShowAppConfig()');
        $this->ShowAppConfig();     // display the app's configuration (name, version...)
        $this->AmHere('ReadUserCommand()');
        $this->ReadUserCommand();   // decode/digest any user request (input) data
        $this->AmHere('DescribeActions()');
        $this->DescribeActions();     // show the UI (this is where the header is displayed - program name/version etc.)
        $this->AmHere('ExecuteActions()');
        $this->ExecuteActions();    // do the actions
    }
    abstract protected function ReadAppConfig();
    abstract protected function ShowAppConfig();
    abstract protected function ReadUserCommand();
    abstract protected function DescribeActions();
    abstract protected function ExecuteActions();

    // -- ACTION -- //

}