Skip to content

Commit 163700d

Browse files
committed
Updating CSharp template.
1 parent 3e86bf3 commit 163700d

11 files changed

+185
-101
lines changed

CommandLine.sln.DotSettings.user

+1-1
Large diffs are not rendered by default.

doc/INFO

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
Command Line Parser Library
2+
--------------------------------------------------------------------------------------------
3+
Project Author/Coordinator: Giacomo Stelluti Scala
4+
Main Contributor(s): Steven Evans, Kevin Moore, Dan Nemec (nemec), Alexander Fast (mizipzor)
5+
--------------------------------------------------------------------------------------------
6+
Version 1.9.5.3 rc0 (*1)
7+
Latest Update: 2013-02-21
8+
9+
Git home:
10+
https://github.com/gsscoder/commandline
11+
12+
General Info:
13+
This library allows command line arguments parsing.
14+
This work were inspired by the GNU LIBC getopt()/getopt_long() functions
15+
(check out: http://www.gnu.org/software/libc/manual/html_node/Getopt.html).
16+
Need a guide on option naming? Check this one:
17+
http://catb.org/~esr/writings/taoup/html/ch10s05.html.
18+
19+
More info on:
20+
[QUICKSTART] http://commandline.codeplex.com/wikipage?title=Quickstart&referringTitle=Documentation
21+
[GUIDE] http://commandline.codeplex.com/documentation (*2)
22+
[BLOG] http://gsscoder.blogspot.com/
23+
24+
Artifact regeneration:
25+
rake strings -> src/libcmdline/Internal/SR.string.cs
26+
rake assemblyinfo -> src/CommonAssemblyInfo.cs
27+
28+
Build (requires Ruby):
29+
gem install rake
30+
gem install albacore
31+
rake
32+
33+
Unit Tests:
34+
rake test
35+
36+
Documentation:
37+
From version 1.9.0.3 Beta CHM HelpFile was removed from {libroot}/doc.
38+
See online documentation section hosted on CodePlex project.
39+
40+
Framework Compatibility:
41+
- C# 3.0+ compiler
42+
- .NET Framework 2.0+
43+
- Mono 2.1+ Profile
44+
45+
Development Environment:
46+
- OS:
47+
Ubuntu 12.04 Desktop (http://www.ubuntu.com/)
48+
Mac OS X Lion (http://www.apple.com/osx/)
49+
Microsoft Windows 7 (http://windows.microsoft.com/en-US/windows/home)
50+
- IDE:
51+
MonoDevelop (http://monodevelop.com/)
52+
MS Visual Studio 2010|2012 (http://www.microsoft.com/visualstudio/eng/visual-studio-update)
53+
- Code Analysis:
54+
JetBrains ReSharper with Open Source License (http://www.jetbrains.com/resharper/)
55+
- Version Control:
56+
Git (http://git-scm.com/)
57+
msysgit (http://code.google.com/p/msysgit/)
58+
SVN (http://subversion.tigris.org/)
59+
- Other Tools:
60+
TextMate (http://macromates.com/)
61+
Scribes (http://scribes.sourceforge.net/)
62+
63+
Test Environment:
64+
- Mac OS X Lion
65+
- Microsoft Windows 7
66+
- Ubuntu 12.04
67+
68+
Licence:
69+
MIT License
70+
http://www.opensource.org/licenses/mit-license.php
71+
72+
Comments, bugs and other:
73+
74+
75+
Enjoy,
76+
Giacomo Stelluti Scala
77+
78+
---------------------------------------------------------------------------------------
79+
[NOTES]
80+
*1) In a production environment you should use a 'stable' version, an 'rc' (release
81+
candidate) or an advanced 'beta' (a 'beta' published for a long time and stated quite stable).
82+
83+
*2) Full documentation is currently under construction. Please refer to Quickstart
84+
guide and informations published starting from the project's home.
85+
---------------------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
44
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
55
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
@@ -9,7 +9,12 @@
99
<OutputType>Exe</OutputType>
1010
<RootNamespace>CSharpTemplate</RootNamespace>
1111
<AssemblyName>CSharpTemplate</AssemblyName>
12-
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileUpgradeFlags>
14+
</FileUpgradeFlags>
15+
<OldToolsVersion>3.5</OldToolsVersion>
16+
<UpgradeBackupLocation />
17+
<TargetFrameworkProfile />
1318
</PropertyGroup>
1419
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
1520
<DebugSymbols>true</DebugSymbols>
@@ -21,6 +26,7 @@
2126
<WarningLevel>4</WarningLevel>
2227
<PlatformTarget>x86</PlatformTarget>
2328
<Externalconsole>true</Externalconsole>
29+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
2430
</PropertyGroup>
2531
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
2632
<DebugType>none</DebugType>
@@ -30,23 +36,22 @@
3036
<WarningLevel>4</WarningLevel>
3137
<PlatformTarget>x86</PlatformTarget>
3238
<Externalconsole>true</Externalconsole>
39+
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>
3340
</PropertyGroup>
3441
<ItemGroup>
42+
<Reference Include="CommandLine">
43+
<HintPath>..\..\libcmdline\bin\Release\CommandLine.dll</HintPath>
44+
</Reference>
3545
<Reference Include="System" />
3646
</ItemGroup>
3747
<ItemGroup>
48+
<Compile Include="Options.cs" />
3849
<Compile Include="Program.cs" />
3950
<Compile Include="Properties\AssemblyInfo.cs" />
4051
<Compile Include="Properties\ThisAssembly.cs" />
41-
<Compile Include="..\..\libcmdline\CommandLine.cs">
42-
<Link>CommandLine.cs</Link>
43-
</Compile>
44-
<Compile Include="..\..\libcmdline\CommandLineText.cs">
45-
<Link>CommandLineText.cs</Link>
46-
</Compile>
4752
</ItemGroup>
4853
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
4954
<ItemGroup>
50-
<Folder Include="Properties\" />
55+
<None Include="app.config" />
5156
</ItemGroup>
5257
</Project>

src/templates/CSharpTemplate/CSharpTemplate.sln

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

2-
Microsoft Visual Studio Solution File, Format Version 10.00
3-
# Visual Studio 2008
2+
Microsoft Visual Studio Solution File, Format Version 11.00
3+
# Visual Studio 2010
44
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CSharpTemplate", "CSharpTemplate.csproj", "{138C670E-473E-4467-A631-3DD0C2181D62}"
55
EndProject
66
Global
@@ -14,6 +14,9 @@ Global
1414
{138C670E-473E-4467-A631-3DD0C2181D62}.Release|x86.ActiveCfg = Release|x86
1515
{138C670E-473E-4467-A631-3DD0C2181D62}.Release|x86.Build.0 = Release|x86
1616
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
1720
GlobalSection(MonoDevelopProperties) = preSolution
1821
StartupItem = CSharpTemplate.csproj
1922
EndGlobalSection
+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#region License
2+
// <copyright file="Options.cs" company="Your name here">
3+
// Copyright 2013 Your name here
4+
// </copyright>
5+
//
6+
// [License Body Here]
7+
#endregion
8+
9+
namespace CSharpTemplate
10+
{
11+
#region Using Directives
12+
using CommandLine;
13+
using CommandLine.Text;
14+
#endregion
15+
16+
internal class Options
17+
{
18+
[Option('t', "text", Required = true, HelpText = "text value here")]
19+
public string TextValue { get; set; }
20+
21+
[Option('n', "numeric", HelpText = "numeric value here")]
22+
public double NumericValue { get; set; }
23+
24+
[Option('b', "bool", HelpText = "on|off switch here")]
25+
public bool BooleanValue { get; set; }
26+
27+
[HelpOption]
28+
public string GetUsage()
29+
{
30+
return HelpText.AutoBuild(this, current => HelpText.DefaultParsingErrorsHandler(this, current));
31+
}
32+
}
33+
}
+26-68
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,33 @@
11
#region License
2-
//
3-
// Your Project Name Here: Program.cs
4-
//
5-
// Author:
6-
// Your Name Here ([email protected])
7-
//
8-
// Copyright (C) 2012 Your Name Here
2+
// <copyright file="Program.cs" company="Your name here">
3+
// Copyright 2013 Your name here
4+
// </copyright>
95
//
106
// [License Body Here]
117
#endregion
12-
#region Using Directives
13-
using System;
14-
using CommandLine;
15-
using CommandLine.Text;
16-
#endregion
178

189
namespace CSharpTemplate
1910
{
20-
sealed class Program
21-
{
22-
sealed class Options : CommandLineOptionsBase
23-
{
24-
[Option("t", "text", Required = true, HelpText = "text value here")]
25-
public string TextValue { get; set; }
26-
27-
[Option("n", "numeric", HelpText = "numeric value here")]
28-
public double NumericValue { get; set; }
29-
30-
[Option("b", "bool", HelpText = "on|off switch here")]
31-
public bool BooleanValue { get; set; }
32-
33-
[HelpOption]
34-
public string GetUsage()
35-
{
36-
var help = new HelpText {
37-
Heading = new HeadingInfo(ThisAssembly.Title, ThisAssembly.InformationalVersion),
38-
Copyright = new CopyrightInfo(ThisAssembly.Author, 2012),
39-
AdditionalNewLineAfterOption = true,
40-
AddDashesToOption = true
41-
};
42-
this.HandleParsingErrorsInHelp(help);
43-
help.AddPreOptionsLine("<<license details here.>>");
44-
help.AddPreOptionsLine("Usage: CSharpTemplate -tSomeText --numeric 2012 -b");
45-
help.AddOptions(this);
46-
47-
return help;
48-
}
49-
50-
void HandleParsingErrorsInHelp(HelpText help)
51-
{
52-
if (this.LastPostParsingState.Errors.Count > 0)
53-
{
54-
var errors = help.RenderParsingErrorsText(this, 2); // indent with two spaces
55-
if (!string.IsNullOrEmpty(errors))
56-
{
57-
help.AddPreOptionsLine(string.Concat(Environment.NewLine, "ERROR(S):"));
58-
help.AddPreOptionsLine(errors);
59-
}
60-
}
61-
}
62-
}
63-
64-
static void Main(string[] args)
65-
{
66-
var options = new Options();
67-
if (CommandLineParser.Default.ParseArguments(args, options))
68-
{
69-
Console.WriteLine("t|ext: " + options.TextValue);
70-
Console.WriteLine("n|umeric: " + options.NumericValue.ToString());
71-
Console.WriteLine("b|ool: " + options.BooleanValue.ToString().ToLower());
72-
}
73-
}
74-
}
75-
}
11+
#region Using Directives
12+
using System;
13+
using CommandLine;
14+
using CommandLine.Text;
15+
#endregion
16+
17+
internal class Program
18+
{
19+
static void Main(string[] args)
20+
{
21+
var options = new Options();
22+
23+
if (!CommandLine.Parser.Default.ParseArguments(args, options))
24+
{
25+
Environment.Exit(CommandLine.Parser.DefaultExitCodeFail);
26+
}
27+
28+
Console.WriteLine("t|ext: " + options.TextValue);
29+
Console.WriteLine("n|umeric: " + options.NumericValue);
30+
Console.WriteLine("b|ool: " + options.BooleanValue.ToString().ToLowerInvariant());
31+
}
32+
}
33+
}

src/templates/CSharpTemplate/Properties/AssemblyInfo.cs

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
#region License
2-
//
3-
// Your Project Name Here: AssemblyInfo.cs
4-
//
5-
// Author:
6-
// Your Name Here ([email protected])
7-
//
8-
// Copyright (C) 2012 Your Name Here
2+
// <copyright file="Assembly.cs" company="Your name here">
3+
// Copyright 2013 Your name here
4+
// </copyright>
95
//
106
// [License Body Here]
117
#endregion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,17 @@
11
#region License
2-
//
3-
// Your Project Name Here: ThisAssembly.cs
4-
//
5-
// Author:
6-
// Your Name Here ([email protected])
7-
//
8-
// Copyright (C) 2012 Your Name Here
2+
// <copyright file="ThisAssembly.cs" company="Your name here">
3+
// Copyright 2013 Your name here
4+
// </copyright>
95
//
106
// [License Body Here]
117
#endregion
128

9+
1310
static class ThisAssembly
1411
{
15-
internal const string Title = "CSharpTemplate";
16-
internal const string Author = "Your Name Here";
17-
internal const string Copyright = "Copyright (C) 2012 " + Author;
18-
internal const string Version = "1.0.0.0"; //alfa?
19-
internal const string InformationalVersion = "1.0.0.0";
20-
}
12+
internal const string Title = "CSharpTemplate";
13+
internal const string Author = "Your name here";
14+
internal const string Copyright = "Copyright (C) 2013 " + Author;
15+
internal const string Version = "1.0.0.0";
16+
internal const string InformationalVersion = "1.0.0-alfa"; // http://semver.org
17+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?xml version="1.0"?>
2+
<configuration>
3+
<startup>
4+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
5+
</startup>
6+
</configuration>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
\\VBOXSVR\Projects_VM\CommandLine\src\templates\CSharpTemplate\bin\Debug\CSharpTemplate.exe.config

0 commit comments

Comments
 (0)