Created
August 20, 2019 08:40
-
-
Save domingoladron/59292620dd843594dd976bdea3910319 to your computer and use it in GitHub Desktop.
dotnet-tool-create-program-cs
This file contains hidden or 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
| using System; | |
| using System.Reflection; | |
| //namespace matches what is in the csproj attributes | |
| namespace SayHowdy | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| //we expect the caller to pass in a simple string on the command line | |
| //if they don't, then we simply echo back what's expected from them | |
| if (args.Length == 0) | |
| { | |
| var versionString = (Assembly.GetEntryAssembly() ?? throw new InvalidOperationException()) | |
| .GetCustomAttribute<AssemblyInformationalVersionAttribute>() | |
| .InformationalVersion; | |
| Console.WriteLine($"sayhowdy v{versionString}"); | |
| Console.WriteLine("-------------"); | |
| Console.WriteLine("\nUsage:"); | |
| Console.WriteLine(" sayhowdy <message>"); | |
| return; | |
| } | |
| SayHowdy(string.Join(' ', args)); | |
| } | |
| static void SayHowdy(string message) | |
| { | |
| string bot = $"Howdy, {message}"; | |
| Console.WriteLine(bot); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment