Futilities/v0.6/clade/Apps/ftm/Opts/@code

From WoozleCodes
Jump to navigation Jump to search
Code Snapshots & Removals

Pages

Current

Code Snapshot: 2026-05-17
interface iOpts extends BaseIface {
    // CONFIG
    // - These need to match the XML WUIDL names.
    const KS_SRCE_PATH = 'str.srce';
    const KS_DEST_PATH = 'str.dest';
    const KI_BUFF_SIZE = 'int.buff.sz';
    // SETTINGS
    function QSrcePath() : QStrIface;
    function QDestPath() : QStrIface;
    public int $NBuffSize { get; }
}
class cOpts extends BaseClass implements iOpts {

    #protected function __construct() {
    #    echo $this->ShowStack(); die();  // to see who is creating this object
    #}

    // ++ CONFIG ++ //

    // These must match ui.xml:
    #const ksOPT_DO_DELETE     = 'opt.del';      // delete after B copy is confirmed to match A
    #const ksOPT_DO_INFO_ONLY  = 'do.info';  // don't actually copy, just show information
    const ksOPT_DO_COMP_FND   = 'opt.comp';     // if target file already found, compare before assuming?
    const ksOPT_IGN_DATE_CHG  = 'opt.ign.date'; // ignore date mismatch
    const ksOPT_FINISH_PART   = 'opt.finish';   // if B smaller than A, see if B is a partial copy of A. Finish copy if so.

    // -- CONFIG -- //
    // ++ SETTINGS ++ //

    public function QSrcePath() : QStrIface { return $this->FetchItQ(self::KS_SRCE_PATH); }
    public function QDestPath() : QStrIface { return $this->FetchItQ(self::KS_DEST_PATH); }
    #[AttrForDebug]
    public int $NBuffSize {
        get { return ($this->FetchItQ(self::KI_BUFF_SIZE))->GetInt(); }
    }

    // OVERRIDE - this app always generates a log
    public function UseLogFile() : bool { return TRUE; }

    // -- SETTINGS -- //
    // ++ OUTPUT: UI ++ //

    public function DescribeSelf() : string {
      $this->ThrowHissy('How is this object even accessed? Needs updating.');
        $doDel = $this->HasCmdOption(self::ksOPT_DO_DELETE);
        if ($doDel) {
            $sVerb = 'Move';
        } else {
            $sVerb = 'Copy';
        }
        $fpSrce = $this->QSrcePath()->GetIt();
        $fpTarg = $this->QDestPath()->GetIt();
        $s = "$sVerb all files in $fpSrce to $fpTarg.\n"
          ."In other words, ensure that everything in A also exists at B:\n"
          ." - A: $fpSrce\n"
          ." - B: $fpTarg"
          ;
        if ($doDel) {
            $s .= "\n ...and delete each file from A after it is confirmed at B.";
        }
        return $s;
    }

    // -- OUTPUT -- //

    // ++ VALUES ++ //

    public function DoDelete() : bool { return $this->HasCmdOption(self::ksOPT_DO_DELETE); }
    public function DoInfoOnly() : bool { return $this->HasCmdOption(self::ksOPT_DO_INFO_ONLY); }
    public function DoCompFound() : bool { return $this->HasCmdOption(self::ksOPT_DO_COMP_FND); }
    public function IgnoreDateDiff() : bool { return $this->HasCmdOption(self::ksOPT_IGN_DATE_CHG); }
    public function DoFinishPartial() : bool { return $this->HasCmdOption(self::ksOPT_FINISH_PART); }

    // -- VALUES -- //
}