common used snippets
WeihanLi opened this issue · comments
Add support for common used snippets
for example:
dotnet-exec 'Guid.NewGuid()'
dotnet-exec snip set new-guid `Guid.NewGuid()`
dotnet-exec snip new-guid
WebApi testing snip
WebApplication.Create().Chain(a => a.Map("/", () => "Hello World")).Run();
dotnet-exec 'WebApplication.Create(args).Chain(a => a.Map("/", () => "Hello World")).Run();' --web -- --urls=http://*:12000
Run-up a PAC script
dotnet-exec 'WebApplication.Create(args).Chain(a => a.Map("/", () => Results.File(Path.Combine(Directory.GetCurrentDirectory(), "pac.txt")))).Run();' --web -- --urls=http://*:33000
Hosting a html page
dotnet-exec 'WebApplication.Create(args).Chain(a => a.Map("/", () => Results.Content(File.ReadAllText(Path.Combine(Directory.GetCurrentDirectory(),"./test-app-banner.html")), "text/html"))).Run();' --web -- --urls=https://*:9120
Hosting static files
dotnet-exec 'WebApplication.Create(args).Chain(a => a.UseStaticFiles()).Run();' --web -- --urls=http://*:5600
Hosting static files with current directory and serve unknown files
dotnet-exec 'WebApplication.CreateBuilder(args).Chain(b => b.Services.AddDirectoryBrowser()).Build().Chain(a => a.UseStaticFiles(new StaticFileOptions{ FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Environment.CurrentDirectory), ServeUnknownFileTypes = true })).Run();' --web -- --urls=http://*:5600
Run up a file server
dotnet-exec 'WebApplication.Create(args).Chain(a => a.UseFileServer()).Run();' --web -- --urls=http://*:5600
Run up a file server with directory browsing
dotnet-exec 'WebApplication.CreateBuilder(args).Chain(b => b.Services.AddDirectoryBrowser()).Build().Chain(a => a.UseFileServer(true)).Run();' --web -- --urls=http://*:5600
file server with current directory
dotnet-exec 'WebApplication.CreateBuilder(args).Chain(b => b.Services.AddDirectoryBrowser()).Build().Chain(a => a.UseFileServer(new FileServerOptions{FileProvider = new Microsoft.Extensions.FileProviders.PhysicalFileProvider(Environment.CurrentDirectory), EnableDirectoryBrowsing = true, EnableDefaultFiles = false})).Run();' --web -- --urls=http://*:5600