Last active
January 14, 2016 22:37
-
-
Save lucamauri/b66f945db30bd4835f10 to your computer and use it in GitHub Desktop.
Template for a prompt module in VB.net
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Module MainPrompt | |
Public Const PromptSymbol As String = "TLA > " | |
Public Const ApplicationTitle As String = "Short name of the application" | |
Sub Main() | |
Dim Statement As String | |
Dim BrokenDownStatement As String() | |
Dim Command As String | |
Dim Args As String() | |
Dim Result As String | |
Console.ForegroundColor = ConsoleColor.Cyan | |
Console.Title = ApplicationTitle & " command line console" | |
Console.WriteLine("Welcome to " & ApplicationTitle & "console frontend") | |
Console.WriteLine("This package is version " & GetType(Project.BaseClass).Assembly.GetName().Version.ToString) | |
Console.WriteLine() | |
Console.Write(PromptSymbol) | |
Do While True | |
Statement = Console.ReadLine() | |
BrokenDownStatement = Statement.Split(" ") | |
ReDim Args(BrokenDownStatement.Length - 1) | |
Command = BrokenDownStatement(0) | |
For i = 1 To BrokenDownStatement.Length - 1 | |
Args(i - 1) = BrokenDownStatement(i) | |
Next | |
Select Case Command.ToLower | |
Case "example" | |
Result = DoSomething(Example) | |
Case "exit", "quit" | |
Exit Do | |
Case "ver" | |
Result = "This package is version " & GetType(Project.BaseClass).Assembly.GetName().Version.ToString | |
Case Else | |
Result = "Command not acknowldged: -" & Command & "-" | |
End Select | |
Console.WriteLine(" " & Result) | |
Console.Write(PromptSymbol) | |
Loop | |
Console.WriteLine("I am exiting, time is " & DateTime.Now.ToString("u")) | |
Console.WriteLine("Goodbye") | |
Environment.Exit(0) | |
End Sub | |
End Module |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment