-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ls sample implementation; incorporate bugfixes
- Loading branch information
1 parent
50bbffd
commit ee54508
Showing
10 changed files
with
276 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
<ProjectGuid>c7615a27-8d3d-466a-9b0b-d6c068b31cb1</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<RootNamespace>Argu.Samples.LS</RootNamespace> | ||
<AssemblyName>ls</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> | ||
<TargetFSharpCoreVersion>4.4.0.0</TargetFSharpCoreVersion> | ||
<Name>Argu.Samples.LS</Name> | ||
<TargetFrameworkProfile /> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<Tailcalls>false</Tailcalls> | ||
<OutputPath>..\bin\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DocumentationFile>..\bin\ls.XML</DocumentationFile> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
<OtherFlags>--standalone</OtherFlags> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<Tailcalls>true</Tailcalls> | ||
<OutputPath>..\bin\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<WarningLevel>3</WarningLevel> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DocumentationFile>..\bin\ls.XML</DocumentationFile> | ||
<Prefer32Bit>true</Prefer32Bit> | ||
<OtherFlags>--standalone</OtherFlags> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="mscorlib" /> | ||
<Reference Include="FSharp.Core, Version=$(TargetFSharpCoreVersion), Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> | ||
<Private>False</Private> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Numerics" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="Arguments.fs" /> | ||
<Compile Include="Program.fs" /> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Argu\Argu.fsproj"> | ||
<Name>Argu</Name> | ||
<Project>{49e38cf1-8b37-4a4f-83cf-eafe9577bcc6}</Project> | ||
<Private>False</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<PropertyGroup> | ||
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion> | ||
</PropertyGroup> | ||
<Choose> | ||
<When Condition="'$(VisualStudioVersion)' == '11.0'"> | ||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets')"> | ||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\..\Microsoft SDKs\F#\3.0\Framework\v4.0\Microsoft.FSharp.Targets</FSharpTargetsPath> | ||
</PropertyGroup> | ||
</When> | ||
<Otherwise> | ||
<PropertyGroup Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets')"> | ||
<FSharpTargetsPath>$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\FSharp\Microsoft.FSharp.Targets</FSharpTargetsPath> | ||
</PropertyGroup> | ||
</Otherwise> | ||
</Choose> | ||
<Import Project="$(FSharpTargetsPath)" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
namespace Argu.Samples.LS | ||
|
||
open Argu | ||
|
||
// This sample attempts to replicate the command line syntax found in | ||
// the GNU coreutils ls command. | ||
|
||
type Size = | ||
| B = 1 | ||
| K = 2 | ||
| M = 3 | ||
| G = 4 | ||
|
||
type ColorWhen = | ||
| Never = 0 | ||
| Always = 1 | ||
| Auto = 2 | ||
|
||
type QuotingStyle = | ||
| Literal = 1 | ||
| Locale = 2 | ||
| Shell = 3 | ||
| Shell_Always = 4 | ||
| Shell_Escape = 5 | ||
| Shell_Escape_Always = 6 | ||
| C = 7 | ||
| Escape = 8 | ||
|
||
[<CliPrefix(CliPrefix.DoubleDash)>] | ||
[<NoAppSettings>] | ||
type LsArguments = | ||
| [<AltCommandLine("-a")>] All | ||
| [<AltCommandLine("-A")>] Almost_All | ||
| Author | ||
| [<AltCommandLine("-b")>] Escape | ||
| [<EqualsAssignment>] Block_Size of SIZE:Size | ||
| [<AltCommandLine("-B")>] Ignore_Backups | ||
| [<AltCommandLine("-C"); EqualsAssignment>] Color of WHEN:ColorWhen option | ||
| [<AltCommandLine("-d")>] Directory | ||
| [<AltCommandLine("-D")>] Dired | ||
| [<CliPrefix(CliPrefix.Dash)>] F | ||
| [<AltCommandLine("-F", "--classify", "--file-type"); EqualsAssignment>] Format of WORD:string option | ||
| [<AltCommandLine("-g")>] Group_Directories_First | ||
| [<AltCommandLine("-G")>] No_Group | ||
| [<AltCommandLine("-h")>] Human_Readable | ||
| [<AltCommandLine("-i")>] INode | ||
| [<AltCommandLine("-I")>] Ignore of PATTERN:string | ||
| [<AltCommandLine("-k")>] KibiBytes | ||
| [<CliPrefix(CliPrefix.Dash)>] L | ||
| [<AltCommandLine("-L")>] Dereference | ||
| [<CliPrefix(CliPrefix.Dash)>] M | ||
| [<AltCommandLine("-n")>] Numeric_Uid_Guid | ||
| [<AltCommandLine("-N")>] Literal | ||
| [<CliPrefix(CliPrefix.Dash)>] O | ||
| [<AltCommandLine("-p"); EqualsAssignment>] Indicator_Style of slash:char | ||
| [<AltCommandLine("-q")>] Hide_Control_Chars | ||
| Show_Control_Chars | ||
| [<AltCommandLine("-Q")>] Quote_Name | ||
| [<EqualsAssignment>] Quoting_Style of WORD:QuotingStyle | ||
| [<AltCommandLine("-r")>] Reverse | ||
| [<AltCommandLine("-R")>] Recursive | ||
| [<AltCommandLine("-s")>] Size | ||
| [<CustomCommandLine("-S")>] S | ||
| [<CliPrefix(CliPrefix.Dash)>] T | ||
| [<AltCommandLine("-T")>] TabSize of COLS:int | ||
| [<CliPrefix(CliPrefix.Dash)>] U | ||
| [<CliPrefix(CliPrefix.Dash)>] V | ||
| [<AltCommandLine("-w")>] Width of COLS:int | ||
| [<CustomCommandLine("-x")>] List_By_Lines | ||
| [<CustomCommandLine("-X")>] Sort_By_Entry | ||
| [<AltCommandLine("-Z")>] Context | ||
| [<CustomCommandLine("-1")>] List_One | ||
| Version | ||
| [<Rest; GatherUnrecognized>] Files of path:string | ||
with | ||
interface IArgParserTemplate with | ||
member arg.Usage = | ||
match arg with | ||
| All -> "do not ignore entries starting with ." | ||
| Almost_All -> "do not list implied . and .." | ||
| Author -> "with -l, print the author of each file" | ||
| Escape -> "print C-style escapes for nongraphic characters" | ||
| Block_Size _ -> "scale sizes by SIZE before printing them; e.g.,\n'--block-size=M' prints sizes in units of\n 1,048,576 bytes" | ||
| Ignore_Backups -> "do not list implied entries ending with ~" | ||
| Color _ -> "colorize the output; WHEN can be 'always' (default\nif omitted), 'auto', or 'never'" | ||
| Directory -> "list directories themselves, not their contents" | ||
| Dired _ -> "generate output designed for Emacs' dired mode" | ||
| F -> "do not sort, enable -aU, disable -ls --color" | ||
| Format _ -> "append indicator (one of */=>@|) to entries" | ||
| Group_Directories_First -> "group directories before files;\ncan be augmented with a --sort option, but any\nuse of --sort=none (-U) disables grouping" | ||
| No_Group -> "in a long listing, don't print group names" | ||
| Human_Readable -> "with -l and/or -s, print human readable sizes\n(e.g., 1K 234M 2G)" | ||
| INode -> "print the index number of each file" | ||
| Ignore _ -> "do not list implied entries matching shell PATTERN" | ||
| KibiBytes -> "default to 1024-byte blocks for disk usage" | ||
| L -> "use a long listing format" | ||
| Dereference -> "when showing file information for a symbolic\nlink, show information for the file the link\nreferences rather than for the link itself" | ||
| M -> "fill width with a comma separated list of entries" | ||
| Numeric_Uid_Guid -> "like -l, but list numeric user and group IDs" | ||
| Literal -> "print raw entry names (don't treat e.g. control\ncharacters specially)" | ||
| O -> "like -l, but do not list group information" | ||
| Indicator_Style _ -> "append / indicator to directories" | ||
| Hide_Control_Chars -> "print ? instead of nongraphic characters" | ||
| Show_Control_Chars -> "show nongraphic characters as-is (the default,\nunless program is 'ls' and output is a terminal)" | ||
| Quote_Name -> "enclose entry names in double quotes" | ||
| Quoting_Style _ -> "use quoting style for entry names" | ||
| Reverse -> "reverse order while sorting" | ||
| Recursive -> "list subdirectories recursively" | ||
| Size -> "print the allocated size of each file, in blocks" | ||
| S -> "sort by file size, largest first" | ||
| T -> "sort by modification time, newest first" | ||
| TabSize _ -> "assume tab stops at each COLS instead of 8" | ||
| U -> "with -lt: sort by, and show, access time;\nwith -l: show access time and sort by name;\notherwise: sort by access time, newest first" | ||
| V -> "natural sort of (version) numbers within text" | ||
| Width _ -> "set output width to COLS. 0 means no limit" | ||
| Context -> "print any security context of each file" | ||
| List_One -> "list one file per line. Avoid '\n' with -q or -b" | ||
| List_By_Lines -> "list entries by lines instead of by columns" | ||
| Sort_By_Entry -> "sort alphabetically by entry extension" | ||
| Version -> "output version information and exit" | ||
| Files _ -> "File expression to list" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
module Argu.Samples.LS.Main | ||
|
||
open System | ||
open Argu | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
let parser = ArgumentParser.Create<LsArguments>(programName = "ls", errorHandler = ProcessExiter()) | ||
|
||
let results = parser.ParseCommandLine argv | ||
|
||
printfn "Got parse results %A" <| results.GetAllResults() | ||
let files = results.GetResults <@ Files @> | ||
printfn "Listing files %A" files | ||
|
||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.