Giter Club home page Giter Club logo

janda.go's Introduction

Janda.Go

.NET NuGet

.NET template provides console application startup code with dependency injection, logging, configuration and more...

Install

To install this template use dotnet command. It will automatically download template nuget package from https://www.nuget.org/packages/Janda.Go

dotnet new -i Janda.Go

Start

Once the template is installed you can create new application from Console Go (C#) template.

dotnet new consolego 

or

dotnet new consolego -n MyApp

The console main code is ready to "Run" with dependency injection and logging.

public void Run()
{
    _logger.LogInformation("Hello, World");
    _logger.LogWarning("No implementation");
    throw new NotImplementedException("Fix it");
}

image

The Program.cs code is going to look like this

// Created with Janda.Go http://github.com/Jandini/Janda.Go
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;

namespace MyApp
{
    class Program
    {
        static void Main()
        {
            try
            {
                using var provider = new ServiceCollection()
                    .AddTransient<IMain, Main>()
                    .AddLogging(builder => builder.AddConsole())
                    .BuildServiceProvider();

                try
                {
                    provider
                        .GetRequiredService<IMain>()
                        .Run();
                }
                catch (Exception ex)
                {
                    provider.GetRequiredService<ILogger<Program>>()
                        .LogCritical(ex, ex.Message);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

Serilog

If you like Serilog the same as I do use --useSerilog or -us option

dotnet new consolego -n MyApp -us

image

Help

More information about Console Go template

dotnet new consolego -h  

Features

  • .NET6
  • Repository Layout
    • The src and bin folders
    • Default README.md file
    • Default .gitignore file
    • Default launchSettings.json file
  • GitHub Actions
    • Build and Test workflow file for .NET6
  • Dependency Injection
    • Main service with logging
    • Service provider disposal
  • Logging
    • Microsoft or Serilog log providers
    • Unhandled exceptions logging
    • Version logging
    • Dynamic logger
  • Configuration
    • Embedded appsettings.json file
    • Override embedded appsettings.json with the file
    • Settings binding
    • Configuration and settings injection
  • Command line parser
    • Verbs and options parser

Resources

Go icon was downloaded from Flaticon.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.