Skip to content

Instantly share code, notes, and snippets.

@Rahtoken
Created April 16, 2023 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rahtoken/45587e6a55f0a7e3fcb45d8eee53b1d4 to your computer and use it in GitHub Desktop.
Save Rahtoken/45587e6a55f0a7e3fcb45d8eee53b1d4 to your computer and use it in GitHub Desktop.
System.CommandLine Example
using System.CommandLine;
var queryArgument = new Argument<string?>(
name: "query",
description: "Ask magi your query!",
getDefaultValue: () => null);
var rootCommand = new RootCommand("magi - Microsoft Graph API's AI");
rootCommand.AddArgument(queryArgument);
var configFileArgument = new Option<string?>(
name: "--config",
description: "magi uses this file as the config.",
getDefaultValue: () => null
);
rootCommand.AddGlobalOption(configFileArgument);
rootCommand.SetHandler(async (query, configFile) =>
{
// LLM + Microsoft Graph API here
}, queryArgument, configFileArgument);
return await rootCommand.InvokeAsync(args);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment