Skip to content

Commit

Permalink
fix console width issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Eirik Tsarpalis committed Dec 20, 2016
1 parent 88d92ef commit 9adb3be
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 3.6.1
* Fix default character width issue in console apps.

### 3.6.0
* Fix wordwrapping issue in usage strings.

Expand Down
4 changes: 1 addition & 3 deletions src/Argu/ArgumentParser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,6 @@ and [<Sealed; NoEquality; NoComparison; AutoSerializable(false)>]
// memoize parser generation for given template type
static let argInfoLazy = lazy(preComputeUnionArgInfo<'Template> ())

static let getUsageWidth() = try min Console.WindowWidth 80 with _ -> 80

let mkUsageString argInfo msgOpt = mkUsageString argInfo _programName false _usageStringCharacterWidth msgOpt |> StringExpr.build

let (|ParserExn|_|) (e : exn) =
Expand All @@ -109,7 +107,7 @@ and [<Sealed; NoEquality; NoComparison; AutoSerializable(false)>]
/// <param name="usageStringCharacterWidth">Text width used when formatting the usage string. Defaults to 80 chars.</param>
/// <param name="errorHandler">The implementation of IExiter used for error handling. Exception is default.</param>
new (?programName : string, ?helpTextMessage : string, ?usageStringCharacterWidth : int, ?errorHandler : IExiter) =
let usageStringCharacterWidth = match usageStringCharacterWidth with None -> getUsageWidth() | Some w -> w
let usageStringCharacterWidth = match usageStringCharacterWidth with None -> getDefaultCharacterWidth() | Some w -> w
let programName = match programName with Some pn -> pn | None -> currentProgramName.Value
let errorHandler = match errorHandler with Some e -> e | None -> new ExceptionExiter() :> _
new ArgumentParser<'Template>(argInfoLazy.Value, programName, helpTextMessage, usageStringCharacterWidth, errorHandler)
Expand Down
8 changes: 4 additions & 4 deletions src/Argu/AssemblyInfo.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
namespace System
open System.Reflection

[<assembly: AssemblyVersionAttribute("3.6.0")>]
[<assembly: AssemblyFileVersionAttribute("3.6.0")>]
[<assembly: AssemblyVersionAttribute("3.6.1")>]
[<assembly: AssemblyFileVersionAttribute("3.6.1")>]
do ()

module internal AssemblyVersionInformation =
let [<Literal>] AssemblyVersion = "3.6.0"
let [<Literal>] AssemblyFileVersion = "3.6.0"
let [<Literal>] AssemblyVersion = "3.6.1"
let [<Literal>] AssemblyFileVersion = "3.6.1"
5 changes: 5 additions & 0 deletions src/Argu/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,11 @@ type PrefixDictionary<'Value>(keyVals : seq<string * 'Value>) =
else kresult <- keys.[maxPos] ; vresult <- values.[maxPos] ; true


/// Gets the default width of the current console window,
/// if available.
let getDefaultCharacterWidth() =
max (try Console.WindowWidth - 1 with _ -> 80) 80

// Wordwrap implementation kindly provided by @forki
let wordwrap (width:int) (inputText:string) =
let breakLine (text:string) (pos:int) (max:int) =
Expand Down
2 changes: 1 addition & 1 deletion src/Argu/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.6.0",
"version": "3.6.1",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
Expand Down
2 changes: 1 addition & 1 deletion tests/Argu.Tests/project.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "3.6.0",
"version": "3.6.1",
"buildOptions": {
"debugType": "portable",
"compilerName": "fsc",
Expand Down

0 comments on commit 9adb3be

Please sign in to comment.