get commandline argument value

master
xieguigang 5 years ago
parent f1d3948dcc
commit 608ded59d5

@ -7,12 +7,16 @@
Public ReadOnly Property ArgumentName As String
Sub New()
Sub New(arg As String)
ArgumentName = arg
End Sub
Public Overrides Function Exec(context As ExecutableContext) As Object
Throw New NotImplementedException()
Return CType(App.CommandLine(ArgumentName), String)
End Function
Public Overrides Function ToString() As String
Return $"$ARGS['{ArgumentName}']"
End Function
End Class
End Namespace

@ -64,8 +64,12 @@ Namespace Interpreter.Expressions
Public Overrides Function Exec(context As ExecutableContext) As Object
If dllName.FileExists Then
Return dllName
Else
Return FindDllFile(context)
End If
End Function
Private Function FindDllFile(context As ExecutableContext) As String
Dim fileName As Value(Of String) = ""
Dim driver As String = dllName
@ -73,7 +77,12 @@ Namespace Interpreter.Expressions
driver = $"{driver}.dll"
End If
For Each dir As String In {App.HOME, App.CurrentDirectory}
For Each dir As String In {
App.HOME,
App.CurrentDirectory,
$"{App.HOME}/Library",
$"{App.HOME}/Drivers"
}
If (fileName = $"{dir}/{driver}").FileExists Then
Return fileName
End If

@ -187,6 +187,8 @@ Namespace Script
t.name = Tokens.Literal Then
Return New Literals(t)
ElseIf t.name = Tokens.CommandLineArgument Then
Return New CommandLineArgument(t.text)
Else
Throw New NotImplementedException
End If
@ -230,7 +232,7 @@ Namespace Script
type = tokenList(3).text
If tokenList.Length > 4 Then
tokenList = tokenList.Skip(4).ToArray
tokenList = tokenList.Skip(5).ToArray
tokenList = tokenList.Take(tokenList.Length - 1).ToArray
Dim values As Token()() = tokenList _

Loading…
Cancel
Save