-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,92 @@ | ||
module NuGetPlay.Main | ||
|
||
open System | ||
open NuGet | ||
open NuGetPlus.ProjectManagement | ||
open UnionArgParser | ||
|
||
type Argument = | ||
| [<MandatoryAttribute>] Action of string | ||
| [<MandatoryAttribute>] ProjectFile of string | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
type Argument = | ||
| Action of string | ||
| ProjectFile of string | ||
| PackageId of string | ||
| Version of string | ||
with | ||
interface IArgParserTemplate with | ||
member s.Usage = | ||
match s with | ||
| Action _ -> "Specify an action: Install, Remove, Restore or Update" | ||
| ProjectFile _ -> "Path to project file to update." | ||
| PackageId _ -> "NuGet package id for action." | ||
| Version _ -> "Optional specific version of package." | ||
interface IArgParserTemplate with | ||
member s.Usage = | ||
match s with | ||
| Action _ -> | ||
"Specify an action: Install, Remove, Restore or Update" | ||
| ProjectFile _ -> "Path to project file to update." | ||
| PackageId _ -> "NuGet package id for action." | ||
| Version _ -> "Optional specific version of package." | ||
|
||
type ActionType = | ||
type ActionType = | ||
| Install | ||
| Remove | ||
| Restore | ||
| Update | ||
|
||
let processAction (a : string) = | ||
let processAction(a : string) = | ||
match a.ToLower() with | ||
| "install" -> Install | ||
| "remove" -> Remove | ||
| "restore" -> Restore | ||
| "update" -> Update | ||
| _ -> failwith "Invalid Action; please use install, remove, restore or update." | ||
| _ -> | ||
failwith | ||
"Invalid Action; please use install, remove, restore or update." | ||
|
||
let processProjectFile (f : string) = | ||
let processProjectFile(f : string) = | ||
match IO.File.Exists(f) with | ||
| true -> f | ||
| false -> failwith "ProjectFile does not exist." | ||
|
||
let processVersion (v : string) = | ||
SemanticVersion(v) | ||
let processVersion(v : string) = SemanticVersion(v) | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
try | ||
try | ||
let parser = UnionArgParser<Argument>() | ||
let results = parser.Parse() | ||
let action = results.PostProcessResult <@ Action @> processAction | ||
let proj = results.PostProcessResult <@ ProjectFile @> processProjectFile | ||
let proj = | ||
results.PostProcessResult <@ ProjectFile @> processProjectFile | ||
let maybePackage = results.TryGetResult <@ PackageId @> | ||
let version = results.TryPostProcessResult <@ Version @> processVersion | ||
|
||
printfn "Action type: %A" action | ||
printfn "Project file: %s" proj | ||
match maybePackage with | ||
| Some package -> | ||
printfn "Package ID: %s" package | ||
| Some package -> printfn "Package ID: %s" package | ||
| None -> () | ||
|
||
match version with | ||
| None -> () | ||
| Some v -> printfn "Version: %A" v | ||
|
||
let checkPackage mp = | ||
let checkPackage mp = | ||
match mp with | ||
| None -> | ||
failwith "A package is required for this action" | ||
| None -> failwith "A package is required for this action" | ||
| Some p -> p | ||
|
||
match action with | ||
| Install -> | ||
| Install -> | ||
match version with | ||
| None -> InstallReference proj (checkPackage maybePackage) | ||
| Some v -> InstallReferenceOfSpecificVersion proj (checkPackage maybePackage) v | ||
| Update -> | ||
| Some v -> | ||
InstallReferenceOfSpecificVersion proj | ||
(checkPackage maybePackage) v | ||
| Update -> | ||
match version with | ||
| None -> UpdateReference proj (checkPackage maybePackage) | ||
| Some v -> UpdateReferenceToSpecificVersion proj (checkPackage maybePackage) v | ||
| Remove -> | ||
RemoveReference proj (checkPackage maybePackage) | ||
| Restore -> | ||
| Some v -> | ||
UpdateReferenceToSpecificVersion proj | ||
(checkPackage maybePackage) v | ||
| Remove -> RemoveReference proj (checkPackage maybePackage) | ||
| Restore -> | ||
match maybePackage with | ||
| Some package -> failwith "PackageId provided for restore action - restore will always restore the whole packages.config" | ||
| Some package -> | ||
failwith | ||
"PackageId provided for restore action - restore will always restore the whole packages.config" | ||
| None -> () | ||
RestoreReferences proj | ||
0 | ||
with | ||
| ex -> | ||
with | ||
| ex -> | ||
printfn "%A" ex | ||
1 | ||
1 |
2 comments
on commit f795575
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was the removal of [] intentional or did fantomas just drop it and it's a bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where? (you can comment on individual lines as well)
It wasn't intentional, to answer the question :).
I'm also undecided whether to keep on using it on the TickSpec step definition files, I'm not sure if I prefer the consistency or having the attributes inline to match the steps better. For the moment though I'm going to try and stick with Go style format everything all the time for a while and see how it goes. Should help providing feedback for Anh-Dung Phan as well.
Here, this two attributes were removed. Please report the bug to fantomas