classdef (Hidden = true, Sealed = true) extendedLaunchCommand
%

%   Copyright 2018 The MathWorks, Inc.
    
    properties (SetAccess = 'private', GetAccess = 'private')
        preCommand = '';
        command = '';
        postCommand = '';
    end
    methods (Sealed = true)
        function this = extendedLaunchCommand(varargin)
            p = inputParser;
            p.addRequired('command', @(x)(~isempty(x) && (ischar(x) || isstring(x))));
            p.addParameter('PreCommand', '', @(x)(ischar(x) || isstring(x)));
            p.addParameter('PostCommand', '', @(x)(ischar(x) || isstring(x)));
            p.parse(varargin{:});
            this.preCommand = p.Results.PreCommand;
            this.command = p.Results.command;
            this.postCommand = p.Results.PostCommand;
        end
        
        function commandString = getCompleteCommand(this)
            commandString = strtrim(sprintf('%s "%s" %s',this.preCommand, this.command, this.postCommand));
        end
        function commandOnly = getCommandOnly(this)
            commandOnly = this.command;
        end
    end
    methods(Static)
        function [quotedString, plainCommand] = getCommandStrings(command)
            p = inputParser;
            p.addRequired('command',@(x)(ischar(command) || isstring(command) || isa(command, 'rtw.connectivity.extendedLaunchCommand')));
            p.parse(command);
            localCommand = p.Results.command;
            if (ischar(localCommand) || isstring(localCommand))
                quotedString = sprintf('"%s"', localCommand);
                plainCommand = localCommand;
            else 
                quotedString = localCommand.getCompleteCommand();
                plainCommand = localCommand.getCommandOnly();
            end            
        end
    end
end
