所以我的问题是我在网上找到的代码。该代码适用于Command Argument
形式的只有一个空格的命令。
我想编辑代码,以便我可以为我的命令添加选项,例如youtube-dl [COMMAND] -i [OPTIONS] URL [URL]
。该命令将有3个空格,但代码只支持一个空格。
如何编辑代码以支持多个参数发送到命令进程?
Public Class Form1
Private psi As ProcessStartInfo
Private cmd As Process
Private Delegate Sub InvokeWithString(ByVal text As String)
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Folder, URL As String
Folder = txtFolder.Text
URL = txtUrl.Text
txtCommand.Text = "C:\Users\Merskies\Desktop\Youtube-dl\youtube-dl.exe -i -o D:\YoutubeDL\" & Folder & "\%%(title)s.%%(ext)s " & URL
Try
cmd.Kill()
Catch ex As Exception
End Try
txtOutput.Clear()
If txtCommand.Text.Contains(" ") Then
psi = New ProcessStartInfo(txtCommand.Text.Split(" ")(0), txtCommand.Text.Split(" ")(1))
Else
psi = New ProcessStartInfo(txtCommand.Text$)
End If
Dim systemencoding As System.Text.Encoding
System.Text.Encoding.GetEncoding(Globalization.CultureInfo.CurrentUICulture.TextInfo.OEMCodePage)
With psi
.UseShellExecute = False
.RedirectStandardError = True
.RedirectStandardOutput = True
.RedirectStandardInput = True
.CreateNoWindow = True
.StandardOutputEncoding = systemencoding
.StandardErrorEncoding = systemencoding
End With
cmd = New Process With {.StartInfo = psi, .EnableRaisingEvents = True}
AddHandler cmd.ErrorDataReceived, AddressOf Async_Data_Received
AddHandler cmd.OutputDataReceived, AddressOf Async_Data_Received
cmd.Start()
cmd.BeginOutputReadLine()
cmd.BeginErrorReadLine()
End Sub
Private Sub Async_Data_Received(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
Me.Invoke(New InvokeWithString(AddressOf Sync_Output), e.Data)
End Sub
Private Sub Sync_Output(ByVal text As String)
txtOutput.AppendText(text & Environment.NewLine)
txtOutput.ScrollToCaret()
End Sub
End Class
答案 0 :(得分:0)
class A
def self.what_is_my_nesting
Module.nesting
end
end
A.what_is_my_nesting
A.ancestors
B.ancestors