コード例 #1
0
ファイル: ScriptPipeline.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="ScriptPipeline"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 /// <param name="scriptLines">The script lines.</param>
 /// <param name="logger">The <see cref="ILogger"/> instance.</param>
 /// <param name="registry">The <see cref="PenshellCommandRegistry"/> instance.</param>
 public ScriptPipeline(
     IPenshellConsole console,
     IEnumerable <ScriptLine> scriptLines,
     ILogger?logger,
     PenshellCommandRegistry registry)
 {
     _console     = console ?? throw new ArgumentNullException(nameof(console));
     _scriptLines = scriptLines;
     _logger      = logger;
     _registry    = registry;
 }
コード例 #2
0
ファイル: StartCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="StartCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public StartCommand(IPenshellConsole console)
     : base(console, "start", "Starts a process.")
 {
     this.AddOption(
         new Option(
             new string[] { "-p", "--path" },
             "The fully qualified name of the file for the new process, or the relative file name.")
     {
         Argument = new Argument <FileInfo>(),
         Required = true,
     });
 }
コード例 #3
0
ファイル: ReadFileCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="ReadFileCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public ReadFileCommand(IPenshellConsole console)
     : base(console, "readfile", "Reads a file.")
 {
     this.AddOption(
         new Option(
             new string[] { "-p", "--path" },
             "The fully qualified name of the file, or the relative file name, to read.")
     {
         Argument = new Argument <FileInfo>(),
         Required = true,
     });
 }
コード例 #4
0
ファイル: AbsCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="AbsCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public AbsCommand(IPenshellConsole console)
     : base(console, "abs", "Returns the absolute value of a specified number.")
 {
     this.AddOption(
         new Option(
             new string[] { "-v", "--value" },
             "A number that is greater than or equal to MinValue, but less than or equal to MaxValue.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
 }
コード例 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenBrowserCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public OpenBrowserCommand(IPenshellConsole console)
     : base(console, "openbrowser", "Opens the browser of a uri.")
 {
     this.AddOption(
         new Option(
             new string[] { "-u", "--uri" },
             "The Uri, which will be opened in the browser.")
     {
         Argument = new Argument <Uri>(),
         Required = true,
     });
 }
コード例 #6
0
ファイル: RunCommand.cs プロジェクト: IForgeDe/Penshell
        /// <summary>
        /// Initializes a new instance of the <see cref="RunCommand"/> class.
        /// </summary>
        /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
        /// <param name="registry">
        /// A <see cref="PenshellCommandRegistry"/> instance.
        /// </param>
        /// <param name="logger">
        /// A <see cref="ILogger"/> instance.
        /// </param>
        public RunCommand(
            IPenshellConsole console,
            PenshellCommandRegistry registry,
            ILogger logger)
            : base(console, "run", "Runs a penshell script.")
        {
            this.Registry = registry;
            this.Logger   = logger;

            this.AddOption(
                new Option(
                    new string[] { "-p", "--path" },
                    "The path to the script.")
            {
                Argument = new Argument <FileInfo>(),
                Required = true,
            });
        }
コード例 #7
0
ファイル: MultiplyCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="MultiplyCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public MultiplyCommand(IPenshellConsole console)
     : base(console, "multiply", "Calculates the multiplication of two values.")
 {
     this.AddOption(
         new Option(
             new string[] { "-x", "--multiplyer" },
             "The multiplyer.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-y", "--multiplicand" },
             "The multiplicand.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DivideCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public DivideCommand(IPenshellConsole console)
     : base(console, "divide", "Calculates the division of two values.")
 {
     this.AddOption(
         new Option(
             new string[] { "-x", "--dividend" },
             "The dividend.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-y", "--divisor" },
             "The devisor.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
 }
コード例 #9
0
ファイル: HttpGetCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="HttpGetCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public HttpGetCommand(IPenshellConsole console)
     : base(console, "httpget", "Gets the response of a http get method call.")
 {
     this.AddOption(
         new Option(
             new string[] { "-u", "--uri" },
             "The uri for the http request.")
     {
         Argument = new Argument <Uri>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-p", "--property" },
             "The property of the response for the output (default is StatusCode).")
     {
         Argument = new Argument <string>(getDefaultValue: () => "StatusCode"),
         Required = false,
     });
 }
コード例 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AddCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public AddCommand(IPenshellConsole console)
     : base(console, "add", "Calculates the addition of two values.")
 {
     this.AddOption(
         new Option(
             new string[] { "-x", "--first" },
             "The first summand.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-y", "--second" },
             "The second summand.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
 }
コード例 #11
0
ファイル: WriteFileCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="WriteFileCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public WriteFileCommand(IPenshellConsole console)
     : base(console, "writefile", "Writes content to a file.")
 {
     this.AddOption(
         new Option(
             new string[] { "-p", "--path" },
             "The fully qualified name of the file, or the relative file name, to write to.")
     {
         Argument = new Argument <FileInfo>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-c", "--content" },
             "The content to write.")
     {
         Argument = new Argument <string>(),
         Required = true,
     });
 }
コード例 #12
0
ファイル: SubstractCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="SubstractCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public SubstractCommand(IPenshellConsole console)
     : base(console, "substract", "Calculates the substraction of two values.")
 {
     this.AddOption(
         new Option(
             new string[] { "-x", "--minuend" },
             "The minuend.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
     this.AddOption(
         new Option(
             new string[] { "-y", "--subtrahend" },
             "The subtrahend.")
     {
         Argument = new Argument <double>(),
         Required = true,
     });
 }
コード例 #13
0
ファイル: SleepCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="SleepCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public SleepCommand(IPenshellConsole console)
     : base(console, "sleep", "Let the current process sleep for a defined time.")
 {
     this.AddOption(
         new Option(
             new string[] { "-H", "--hours" },
             "The time in hours that the process should sleep.")
     {
         Argument = new Argument <int>(),
         Required = false,
     });
     this.AddOption(
         new Option(
             new string[] { "-z", "--milliseconds" },
             "The time in milliseconds that the process should sleep.")
     {
         Argument = new Argument <int>(),
         Required = false,
     });
     this.AddOption(
         new Option(
             new string[] { "-m", "--minutes" },
             "The time in minutes that the process should sleep.")
     {
         Argument = new Argument <int>(),
         Required = false,
     });
     this.AddOption(
         new Option(
             new string[] { "-s", "--seconds" },
             "The time in seconds that the process should sleep.")
     {
         Argument = new Argument <int>(),
         Required = false,
     });
 }
コード例 #14
0
ファイル: PenshellCommand.cs プロジェクト: IForgeDe/Penshell
 /// <summary>
 /// Initializes a new instance of the <see cref="PenshellCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 /// <param name="name">The name.</param>
 /// <param name="description">The desciption.</param>
 protected PenshellCommand(IPenshellConsole console, string name, string?description = null)
     : base(name, description)
 {
     this.Console = console ?? throw new ArgumentNullException(nameof(console));
     this.Handler = this.CreateCommandHandler();
 }
コード例 #15
0
 /// <summary>
 /// A fluent method to inject a <see cref="IPenshellConsole"/> instance.
 /// </summary>
 /// <param name="console">
 /// The <see cref="IPenshellConsole"/> instance.
 /// </param>
 /// <returns>
 /// The fluent instance.
 /// </returns>
 public ScriptPipelineBuilder UseConsole(IPenshellConsole console)
 {
     _console = console;
     return(this);
 }
コード例 #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExitCommand"/> class.
 /// </summary>
 /// <param name="console">The <see cref="IPenshellConsole"/> instance.</param>
 public ExitCommand(IPenshellConsole console)
     : base(console, "exit", "Exits a penshell script.")
 {
 }