GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — scriptcs/src/ScriptCs/Program.cs at dev · scriptcs/scriptcs

Expand file tree

/

Program.cs

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
114 lines (100 loc) · 5.87 KB
/

Program.cs

Copy path

File metadata and controls

114 lines (100 loc) · 5.87 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
using McMaster.Extensions.CommandLineUtils;
using ScriptCs.Contracts;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
namespace ScriptCs
{
internal static class Program
{
[LoaderOptimizationAttribute(LoaderOptimization.MultiDomain)]
private static int Main(string[] args)
{
//args = args.Skip(2).ToArray();
ProfileOptimizationShim.SetProfileRoot(Path.GetDirectoryName(typeof(Program).Assembly.Location));
ProfileOptimizationShim.StartProfile(typeof(Program).Assembly.GetName().Name + ".profile");
var nonScriptArgs = args.TakeWhile(arg => arg != "--").ToArray();
var scriptArgs = args.Skip(nonScriptArgs.Length + 1).ToArray();
var app = new CommandLineApplication(throwOnUnexpectedArg: true)
{
ExtendedHelpText = "Usage: scriptcs options",
OptionsComparison = StringComparison.OrdinalIgnoreCase
};
var script = app.Argument("script", "Script file name, must be specified first");
var scriptNameFallback = app.Option("--scriptname | -script", "Alternative way to pass a script filename", CommandOptionType.NoValue);
var repl = app.Option("--repl | -r", "Launch REPL mode when running script. To just launch REPL, simply omit the 'script' argument", CommandOptionType.NoValue);
var eval = app.Option("--eval | -e", "Code to immediately evaluate", CommandOptionType.SingleValue);
var configFile = app.Option("--config | -co", "Defines config file name", CommandOptionType.SingleValue);
var debug = app.Option("--debug | -d", "Emits PDB symbols allowing for attaching a Visual Studio debugger", CommandOptionType.NoValue);
var version = app.Option("--version | -v", "Outputs version information", CommandOptionType.NoValue);
var cache = app.Option("--cache | -c", "Flag which determines whether to run in memory or from a .dll", CommandOptionType.NoValue);
var logLevel = app.Option<LogLevel?>("--loglevel | -log", "Flag which defines the log level used", CommandOptionType.SingleValue);
var watch = app.Option("--watch | -w", "Watch the script file and reload it when changed", CommandOptionType.NoValue);
var modules = app.Option("--modules | -m", "Specify modules to load (comma separated)", CommandOptionType.SingleValue);
var output = app.Option("--output | -o", "Write all console output to the specified file", CommandOptionType.SingleValue);
app.HelpOption("-Help | -?");
app.Command("install", c =>
{
var package = c.Argument("package", "Specific package to install, otherwise installs and restores packages which are specified in packages.config");
var allowPrerelease = c.Option("--allowprerelease | -pre", "Allows installation of packages' prelease versions", CommandOptionType.NoValue);
var packageVersion = c.Option("--packageversion | -p", "Defines the version of the package to install", CommandOptionType.SingleValue);
var save = c.Option("--save | -s", "Creates a packages.config file based on the packages directory", CommandOptionType.NoValue);
var clean = c.Option("--clean | -cl", "Cleans installed packages from working directory", CommandOptionType.NoValue);
var global = c.Option("--global | -g", "Installs and restores global packages which are specified in packages.config", CommandOptionType.NoValue);
c.OnExecute(() =>
{
var configMask = new ConfigMask
{
Repl = false,
Global = global.HasValue() ? true : (bool?)null,
Install = package.Value ?? string.Empty, // needed to trigger install of all packages!
PackageVersion = packageVersion.Value(),
AllowPreRelease = allowPrerelease.HasValue() ? true : (bool?)null,
Save = save.HasValue() ? true : (bool?)null,
Clean = clean.HasValue() ? true : (bool?)null,
Output = output.Value(),
Debug = debug.HasValue() ? true : (bool?)null,
LogLevel = logLevel.ParsedValue
};
return Application.Run(Config.Create(configFile.Value(), configMask), scriptArgs);
});
});
app.OnExecute(() =>
{
if (configFile.HasValue() && !File.Exists(configFile.Value()))
{
Console.WriteLine("The specified config file does not exist.");
return 1;
}
if (version.HasValue())
{
VersionWriter.Write();
return 0;
}
var configMask = new ConfigMask
{
Repl = repl.HasValue() ? true : (bool?)null,
ScriptName = scriptNameFallback.HasValue() ? scriptNameFallback.Value() : script.Value,
Debug = debug.HasValue() ? true : (bool?)null,
Eval = eval.Value(),
Cache = cache.HasValue() ? true : (bool?)null,
Watch = watch.HasValue() ? true : (bool?)null,
LogLevel = logLevel.ParsedValue,
Modules = modules.Value(),
Output = output.Value()
};
return Application.Run(Config.Create(configFile.Value(), configMask), scriptArgs);
});
try
{
return app.Execute(nonScriptArgs);
}
catch (CommandParsingException)
{
app.ShowHelp();
return 1;
}
}
}
}
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.