broken/ef
Paul Schneider 3 years ago
parent 4cec5d0229
commit 3086cc65c4
6 changed files with 208 additions and 0 deletions

2
.gitignore vendored

@ -5,3 +5,5 @@ test/nuget.host.tests/bin/
test/nuget.host.tests/obj
src/nuget-host/bin/
src/nuget-host/obj/
src/nuget-cli/obj
src/nuget-cli/bin

@ -24,6 +24,28 @@
"sourceFileMap": {
"/Views": "${workspaceFolder}/src/nuget-host/Views"
}
},
{
"name": ".NET Core Launch cli",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "buildcli",
"program": "${workspaceFolder}/src/nuget-cli/bin/Debug/netcoreapp2.1/nuget-cli.dll",
"args": [ "push",
"-k", "lame-aki-key",
"-s", "http://localhost:5000/packages",
"lame.nupkg"
],
"cwd": "${workspaceFolder}/src/nuget-cli",
"stopAtEntry": false,
"requireExactSource": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\\\bNow listening on:\\\\s+(https?://\\\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
]
}

15
.vscode/tasks.json vendored

@ -19,6 +19,21 @@
"type": "process",
"args": [
"build",
"src/nuget-host",
"/p:Configuration=Debug",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",
"--ignore-failed-sources"
],
"problemMatcher": "$msCompile"
},
{
"label": "buildcli",
"command": "dotnet",
"type": "process",
"args": [
"build",
"src/nuget-cli",
"/p:Configuration=Debug",
"/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary",

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
namespace nuget_cli
{
partial class Program
{
private static void SourceList(IEnumerable<string> sargs)
{
throw new NotImplementedException();
}
private static object SourceAdd(IEnumerable<string> str)
{
throw new NotImplementedException();
}
private static object Add(IEnumerable<string> str)
{
throw new NotImplementedException();
}
private static object PushPkg(IEnumerable<string> pkg)
{
throw new NotImplementedException();
}
private static object StoreApiKey(IEnumerable<string> str)
{
throw new NotImplementedException();
}
private static string LocalizeThis(string arg)
{
return arg;
}
}
}

@ -0,0 +1,119 @@
using System;
using System.Collections.Generic;
using Mono.Options;
namespace nuget_cli
{
partial class Program
{
private static bool shouldShowHelp;
private static bool shouldShowSourceHelp;
private static bool shouldShowPushHelp;
private static string apiKey = null;
private static string source = null;
static void Main(string[] args)
{
var options = new OptionSet {
{ "h|help", "show this message and exit", h => shouldShowHelp = h != null },
};
var pushoptions = new OptionSet {
{ "k|api-key=", "use api key", val => apiKey = apiKey ?? val },
{ "s|source=", "use source", val => source = source ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
};
var sourceoptions = new OptionSet {
{ "h|help", "show this message and exit", h => shouldShowSourceHelp = h != null },
};
var commandSet = new CommandSet("yaget-cli");
var srclst = new Command("list")
{
Run = sargs => SourceList(sargs)
};
var srcadd = new Command("add")
{
Run = sargs => SourceAdd(sargs)
};
var srcCmd = new Command("source")
{
Run = sargs =>
{
var pargs = sourceoptions.Parse(sargs);
if (shouldShowSourceHelp)
{
// output the options
Console.WriteLine("Push Options:");
sourceoptions.WriteOptionDescriptions(Console.Out);
return;
}
}
};
var sourceCmdSet = new CommandSet("source")
{
srclst,
srcadd
};
var add = new Command("add")
{
Run = sargs => Add(sargs)
};
commandSet.Add(add);
var push = new Command("push")
{
Run = sargs =>
{
var pargs = pushoptions.Parse(sargs);
if (shouldShowPushHelp)
{
// output the options
Console.WriteLine("Push Options:");
pushoptions.WriteOptionDescriptions(Console.Out);
return;
}
PushPkg(pargs);
}
};
commandSet.Add(push);
var setapikey = new Command("set-api-key")
{
Run = sargs => StoreApiKey(sargs)
};
commandSet.Add(setapikey);
List<string> extra;
try
{
// parse the command line
extra = options.Parse(args);
}
catch (OptionException e)
{
// output some error message
Console.Write("nuget-cli: ");
Console.WriteLine(e.Message);
Console.WriteLine("Try `nuget-cli --help' for more information.");
return;
}
if (shouldShowHelp)
{
// output the options
Console.WriteLine("Options:");
options.WriteOptionDescriptions(Console.Out);
return;
}
commandSet.Run(args);
}
}
}

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>nuget_cli</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Mono.Options" Version="5.3.0" />
</ItemGroup>
</Project>
Loading…