Skip to content

Instantly share code, notes, and snippets.

@domingoladron
Created August 20, 2019 08:40
Show Gist options
  • Select an option

  • Save domingoladron/59292620dd843594dd976bdea3910319 to your computer and use it in GitHub Desktop.

Select an option

Save domingoladron/59292620dd843594dd976bdea3910319 to your computer and use it in GitHub Desktop.
dotnet-tool-create-program-cs
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