namespace Microsoft.PowerShell.Linux.Host
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Management.Automation;
using System.Management.Automation.Host;
using System.Management.Automation.Runspaces;
using System.Text;
using System.IO;
using System.Runtime.InteropServices;
using PowerShell = System.Management.Automation.PowerShell;
public static class Program
{
///
/// Creates and initiates the listener instance.
///
public static void Main(string[] args)
{
// Setup the Assembly Load Context, which Core PowerShell uses to
// analyze the libraries for types, functions, cmdlets, etc. and
// provide the ability to load assemblies by file path. Doing this
// here eliminates the need for a custom native host.
PowerShellAssemblyLoadContextInitializer.SetPowerShellAssemblyLoadContext(AppContext.BaseDirectory);
// Argument parsing
string initialScript = null;
bool loadProfiles = true;
if (args.Length > 0)
{
for (int i = 0; i < args.Length; ++i)
{
string arg = args[i];
bool hasNext = (i+1) < args.Length;
string nextArg = hasNext ? args[i+1] : string.Empty;
// --help was specified
if (arg == "--help" || arg == "-h")
{
Console.WriteLine(@"
usage: powershell[.exe] [ (--help | -h) ]
[ (--file | -f) ]
[