/// <summary> /// Standard input redirection as in bash. The given <paramref name="file"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, FileInfo file) { Throw.IfNull(command, "command"); return(command.RedirectFrom(file)); }
/// <summary> /// Standard input redirection as in bash. The items in <paramref name="lines"/> are written to the <see cref="Command"/>'s /// standard output as lines of text. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the /// progress of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, IEnumerable <string> lines) { Throw.IfNull(command, "command"); return(command.RedirectFrom(lines)); }
/// <summary> /// Standard input redirection as in bash. The items in <paramref name="chars"/> are written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the /// progress of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, IEnumerable <char> chars) { Throw.IfNull(command, "command"); return(new IoCommand(command, command.StandardInput.PipeFromAsync(chars))); }
/// <summary> /// Standard error redirection as in bash. The <see cref="Command"/>'s standard error is written to the given /// <paramref name="stream"/>. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectStandardErrorTo(Stream stream) { Throw.IfNull(stream, nameof(stream)); return(new IoCommand(this, this.StandardError.PipeToAsync(stream, leaveStreamOpen: true))); }
/// <summary> /// Throws an <see cref="ArgumentNullException"/> if the given value is null /// </summary> public static void IfNull <T>(T value, string parameterName) { Throw <ArgumentNullException> .If(value == null, parameterName); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="stream"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, Stream stream) { Throw.IfNull(command, "command"); return(new IoCommand(command, command.StandardInput.PipeFromAsync(stream, leaveStreamOpen: true))); }
/// <summary> /// Standard error redirection as in bash. The chars of <see cref="Command"/>'s standard error are added to the given /// collection (<paramref name="chars"/> Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks /// the progress of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectStandardErrorTo(ICollection <char> chars) { Throw.IfNull(chars, nameof(chars)); return(new IoCommand(this, this.StandardError.PipeToAsync(chars))); }
/// <summary> /// Creates a shell whose commands will receive the given configuration options /// </summary> public Shell(Action <Options> options) { Throw.IfNull(options, nameof(options)); this.Configuration = options; }
/// <summary> /// Standard error redirection as in bash. The lines of <see cref="Command"/>'s standard error are added to the given /// collection (<paramref name="lines"/> Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks /// the progress of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectStandardErrorTo(ICollection <string> lines) { Throw.IfNull(lines, nameof(lines)); return(new IoCommand(this, this.StandardError.PipeToAsync(lines))); }
/// <summary> /// Standard input redirection as in bash. The items in <paramref name="lines"/> are written to the <see cref="Command"/>'s /// standard output as lines of text. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the /// progress of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectFrom(IEnumerable <string> lines) { Throw.IfNull(lines, nameof(lines)); return(new IoCommand(this, this.StandardInput.PipeFromAsync(lines))); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="file"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectFrom(FileInfo file) { Throw.IfNull(file, nameof(file)); return(new IoCommand(this, this.StandardInput.PipeFromAsync(file))); }
/// <summary> /// Standard error redirection as in bash. The <see cref="Command"/>'s standard error is written to the given /// <paramref name="file"/>. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectStandardErrorTo(FileInfo file) { Throw.IfNull(file, nameof(file)); return(new IoCommand(this, this.StandardError.PipeToAsync(file))); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="stream"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectFrom(Stream stream) { Throw.IfNull(stream, nameof(stream)); return(new IoCommand(this, this.StandardInput.PipeFromAsync(stream, leaveStreamOpen: true))); }
/// <summary> /// Standard input redirection as in bash. The items in <paramref name="chars"/> are written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the /// progress of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, IEnumerable <char> chars) { Throw.IfNull(command, "command"); return(command.RedirectFrom(chars)); }
/// <summary> /// Standard input redirection as in bash. The items in <paramref name="chars"/> are written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the /// progress of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectFrom(IEnumerable <char> chars) { Throw.IfNull(chars, nameof(chars)); return(new IoCommand(this, this.StandardInput.PipeFromAsync(chars))); }
/// <summary> /// Executes the given <paramref name="executable"/> with the given <paramref name="arguments"/> /// </summary> public Command Run(string executable, params object[] arguments) { Throw.IfNull(arguments, "arguments"); return(this.Run(executable, arguments.AsEnumerable())); }
/// <summary> /// Standard error redirection as in bash. The <see cref="Command"/>'s standard error is written to the given /// <paramref name="writer"/>. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectStandardErrorTo(TextWriter writer) { Throw.IfNull(writer, nameof(writer)); return(new IoCommand(this, this.StandardError.PipeToAsync(writer, leaveWriterOpen: true))); }
/// <summary> /// Adds or overwrites an environment variable to be passed to the <see cref="Medallion.Shell.Command"/> /// </summary> public Options EnvironmentVariable(string name, string value) { Throw.If(string.IsNullOrEmpty(name), "name is required"); return(this.StartInfo(psi => psi.EnvironmentVariables[name] = value)); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="reader"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public Command RedirectFrom(TextReader reader) { Throw.IfNull(reader, nameof(reader)); return(new IoCommand(this, this.StandardInput.PipeFromAsync(reader, leaveReaderOpen: true))); }
/// <summary> /// Throws an <see cref="ArgumentException"/> if the given condition is true /// </summary> public static void If(bool condition, string parameterName) { Throw <ArgumentException> .If(condition, parameterName); }
/// <summary> /// Implements <see cref="Command"/> piping as in bash. The first <see cref="Command"/>'s standard output is piped /// to the second's standard input. Returns a new <see cref="Command"/> instance whose <see cref="Command.Task"/> tracks /// the progress of the entire chain /// </summary> public static Command operator |(Command first, Command second) { Throw.IfNull(first, "first"); return(first.PipeTo(second)); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="file"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, FileInfo file) { Throw.IfNull(command, "command"); return(new IoCommand(command, command.StandardInput.PipeFromAsync(file))); }
/// <summary> /// Standard input redirection as in bash. The given <paramref name="stream"/> is written to the <see cref="Command"/>'s /// standard output. Returns a new <see cref="Command"/> whose <see cref="Command.Task"/> tracks the progress /// of both this <see cref="Command"/> and the IO being performed /// </summary> public static Command operator <(Command command, Stream stream) { Throw.IfNull(command, "command"); return(command.RedirectFrom(stream)); }
/// <summary> /// Throws <see cref="ObjectDisposedException"/> if the <see cref="Command"/> has been disposed /// </summary> protected void ThrowIfDisposed() { Throw <ObjectDisposedException> .If(Volatile.Read(ref this._disposed) != 0, () => this.ToString()); }
/// <summary> /// Implements <see cref="Command"/> piping as in bash. The first <see cref="Command"/>'s standard output is piped /// to the second's standard input. Returns a new <see cref="Command"/> instance whose <see cref="Command.Task"/> tracks /// the progress of the entire chain /// </summary> public Command PipeTo(Command second) { Throw.IfNull(second, nameof(second)); return(new PipedCommand(this, second)); }