Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format commands help #639

Merged
merged 28 commits into from
Feb 23, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8e6847a
Treat config as a command in docs
theimowski Feb 20, 2015
4a48a9a
auto generate syntax for install command
theimowski Feb 20, 2015
fcfe45c
add Syntax member to CommandHelpTopic
theimowski Feb 21, 2015
96ccbed
automatic syntax for Install command
theimowski Feb 21, 2015
0c93c0c
print help for Install command
theimowski Feb 21, 2015
2205f54
correct title for convert command
theimowski Feb 21, 2015
10e2430
extract helper fun processCommand
theimowski Feb 21, 2015
7706da2
migrate add command
theimowski Feb 21, 2015
3586355
migrate auto-restore
theimowski Feb 21, 2015
049666d
migrate config command
theimowski Feb 21, 2015
7c7017c
migrate convert-from-nuget
theimowski Feb 21, 2015
7c5826e
migrate find-refs command
theimowski Feb 21, 2015
e345a7b
migrate init
theimowski Feb 21, 2015
0c429c9
migrate outdated
theimowski Feb 21, 2015
8dacac4
for rest of commands use processCommand helper fun
theimowski Feb 21, 2015
cc41870
fill in a 2 more command args - 4 yet to go
theimowski Feb 21, 2015
f52afbd
fix typos
theimowski Feb 22, 2015
7682922
fill the args for remaining commands
theimowski Feb 22, 2015
182ede1
canonicalize convert-from-nuget command docs
theimowski Feb 22, 2015
5c2cdb6
make commands from HelpTexts lazy
theimowski Feb 22, 2015
8d7c677
print usage for Command DU
theimowski Feb 22, 2015
eb10146
read command name from attribute
theimowski Feb 22, 2015
a900114
fill usages for Command DU
theimowski Feb 22, 2015
2960a52
canonicalize config command documentation
theimowski Feb 22, 2015
95bed53
extract syntax docs
theimowski Feb 22, 2015
f202192
cleanup Program.fs
theimowski Feb 22, 2015
312b31e
help texts - list instead of dict
theimowski Feb 22, 2015
a2df3a7
cleanup
theimowski Feb 22, 2015
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Paket.sln
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "content", "content", "{8E6D
docs\content\index.md = docs\content\index.md
docs\content\lock-file.md = docs\content\lock-file.md
docs\content\nuget-dependencies.md = docs\content\nuget-dependencies.md
docs\content\paket-config-file.md = docs\content\paket-config-file.md
docs\content\paket.dependencies = docs\content\paket.dependencies
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this gone?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I treat config as a command so it's now generated from the HelpTexts class.
Eventually we'll be able to fallback to separate md file for each command when this PR is merged

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool. just tell me when it's ready to merge - really cool stuff

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, I think it's ready now - I took it even a step further.

docs\content\reference-from-repl.fsx = docs\content\reference-from-repl.fsx
docs\content\references-files.md = docs\content\references-files.md
Expand Down
9 changes: 8 additions & 1 deletion docs/content/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,14 @@ Instead we encourage the .NET community to use a declarative install process and

## I'm already using NuGet. How can I convert to Paket?

The process is very easy and you can read more about it in the [convert from NuGet](paket-convert-from-nuget.html) section.
The process can be automated with [paket convert-from-nuget](paket-convert-from-nuget.html) command.

In case of the command's failure, you can fallback to manual approach:

1. Analyse your `packages.config` files and extract the referenced packages into a paket.dependencies file.
2. Convert each `packages.config` file to a paket.references file. This is very easy - you just have to remove all the XML and keep the package names.
3. Run [paket install](paket-install.html) with the `--hard` flag. This will analyze the dependencies, generate a paket.lock file, remove all the old package references from your project files and replace them with equivalent `Reference`s in a syntax that can be managed automatically by Paket.
4. (Optional) Raise corresponding issue [here](https://github.com/fsprojects/Paket/issues) so that we can make the comand even better.

## Why should I commit the lock file?

Expand Down
17 changes: 0 additions & 17 deletions docs/content/paket-config-file.md

This file was deleted.

5 changes: 3 additions & 2 deletions docs/tools/generate.fsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/// Getting help docs from Paket.exe
#r "../../bin/UnionArgParser.dll"
#r "../../bin/Paket.exe"
open System.IO

Paket.HelpTexts.commands
|> Seq.iter (fun kv -> File.WriteAllText(sprintf "../content/paket-%s.md" kv.Key,kv.Value.ToMarkDown()))
Paket.HelpTexts.commands.Force()
|> Seq.iter (fun ht -> File.WriteAllText(sprintf "../content/paket-%s.md" ht.Command.Name, Paket.Commands.markdown ht.Command ht.Text))

// --------------------------------------------------------------------------------------
// Builds the documentation from `.fsx` and `.md` files in the 'docs/content' directory
Expand Down
2 changes: 1 addition & 1 deletion docs/tools/templates/template.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<li class="nav-header">Paket commands</li>
<li><a href="@Root/paket-add.html">paket add</a></li>
<li><a href="@Root/paket-auto-restore.html">paket auto-restore</a></li>
<li><a href="@Root/paket-config.html">paket config</a></li>
<li><a href="@Root/paket-convert-from-nuget.html">paket convert-from-nuget</a></li>
<li><a href="@Root/paket-find-refs.html">paket find-refs</a></li>
<li><a href="@Root/paket-init.html">paket init</a></li>
Expand All @@ -77,7 +78,6 @@
<li class="divider"></li>
<li><a href="@Root/paket-folder.html">.paket folder</a></li>
<li><a href="@Root/bootstrapper.html">paket.bootstrapper.exe</a></li>
<li><a href="@Root/paket-config-file.html">paket.config</a></li>
</ul>
</div>
</div>
Expand Down
176 changes: 161 additions & 15 deletions src/Paket/Commands.fs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
module Paket.Commands

open System

open Nessos.UnionArgParser

type Command =
Expand All @@ -19,8 +21,29 @@ type Command =
| [<First>][<CustomCommandLine("push")>] Push
with
interface IArgParserTemplate with
member __.Usage = ""

member this.Usage =
match this with
| Add -> "Adds a new package to your paket.dependencies file."
| Config -> "Allows to store global configuration values like NuGet credentials."
| ConvertFromNuget -> "Converts from using NuGet to Paket."
| FindRefs -> "Finds all project files that have the given NuGet packages installed."
| Init -> "Creates empty paket.dependencies file in the working directory."
| AutoRestore -> "Enables or disables automatic Package Restore in Visual Studio during the build process."
| Install -> "Ensures that all dependencies in your paket.dependencies file are present in the `packages` directory and referenced correctly in all projects."
| Outdated -> "Lists all dependencies that have newer versions available."
| Remove -> "Removes a package from your paket.dependencies file and all paket.references files."
| Restore -> "Ensures that all dependencies in your paket.dependencies file are present in the `packages` directory."
| Simplify -> "Simplifies your paket.dependencies file by removing transitive dependencies."
| Update -> "Recomputes the dependency resolution, updates the paket.lock file and propagates any resulting package changes into all project files referencing updated packages."
| Pack -> "Packs all paket.template files within this repository"
| Push -> "Pushes all `.nupkg` files from the given directory."

member this.Name =
let uci,_ = Microsoft.FSharp.Reflection.FSharpValue.GetUnionFields(this, typeof<Command>)
(uci.GetCustomAttributes(typeof<CustomCommandLineAttribute>)
|> Seq.head
:?> CustomCommandLineAttribute).Name

type GlobalArgs =
| [<AltCommandLine("-v")>] Verbose
| Log_File of string
Expand All @@ -38,13 +61,23 @@ type AddArgs =
| No_Install
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Nuget(_) -> "Nuget package id."
| Version(_) -> "Allows to specify version of the package."
| Project(_) -> "Allows to add the package to a single project only."
| Force -> "Forces the download and reinstallation of all packages."
| Interactive -> "Asks the user for every project if he or she wants to add the package to the projects's paket.references file."
| Hard -> "Replaces package references within project files even if they are not yet adhering to the Paket's conventions (and hence considered manually managed)."
| No_Install -> "Skips paket install --hard process afterward generation of dependencies / references files."

type ConfigArgs =
| [<CustomCommandLine("add-credentials")>] AddCredentials of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| AddCredentials(_) -> "Add credentials for the specified Nuget feed"

type ConvertFromNugetArgs =
| [<AltCommandLine("-f")>] Force
Expand All @@ -53,13 +86,20 @@ type ConvertFromNugetArgs =
| Creds_Migration of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Force -> "Forces the conversion, even if a paket.dependencies file or paket.references files are present."
| No_Install -> "Skips paket install --hard process afterward generation of dependencies / references files."
| No_Auto_Restore -> "Skips paket auto-restore process afterward generation of dependencies / references files."
| Creds_Migration(_) -> "Specify mode for migrating NuGet source credentials. Possible values are [`encrypt`|`plaintext`|`selective`]. The default mode is `encrypt`."

type FindRefsArgs =
| [<Rest>][<CustomCommandLine("nuget")>][<Mandatory>] Packages of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Packages(_) -> "List of packages."

type InitArgs =
| [<Hidden>] NoArg
Expand All @@ -72,22 +112,32 @@ type AutoRestoreArgs =
| [<First>][<CustomCommandLine("off")>] Off
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| On -> "Turns auto restore on"
| Off -> "Turns auto restore off"

type InstallArgs =
| [<AltCommandLine("-f")>] Force
| Hard
| Redirects
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Force -> "Forces the download and reinstallation of all packages."
| Hard -> "Replaces package references within project files even if they are not yet adhering to the Paket's conventions (and hence considered manually managed)."
| Redirects -> "Creates binding redirects for the NuGet packages."

type OutdatedArgs =
| Ignore_Constraints
| [<AltCommandLine("--pre")>] Include_Prereleases
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Ignore_Constraints -> "Ignores the version requirement as in the paket.dependencies file."
| Include_Prereleases -> "Includes prereleases."

type RemoveArgs =
| [<CustomCommandLine("nuget")>][<Mandatory>] Nuget of string
Expand All @@ -98,20 +148,32 @@ type RemoveArgs =
| No_Install
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Nuget(_) -> "Nuget package id."
| Project(_) -> "Allows to add the package to a single project only."
| Force -> "Forces the download and reinstallation of all packages."
| Interactive -> "Asks the user for every project if he or she wants to remove the package from the projects's paket.references file. By default every installation of the package is removed."
| Hard -> "Replaces package references within project files even if they are not yet adhering to the Paket's conventions (and hence considered manually managed)."
| No_Install -> "Skips paket install --hard process afterward generation of dependencies / references files."

type RestoreArgs =
| [<AltCommandLine("-f")>] Force
| [<Rest>] References_Files of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Force -> "Forces the download of all packages."
| References_Files(_) -> "Allows to restore all packages from the given paket.references files. If no paket.references file is given then all packages will be restored."

type SimplifyArgs =
| [<AltCommandLine("-i")>] Interactive
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Interactive -> "Asks to confirm to delete every transitive dependency from each of the files."

type UpdateArgs =
| [<CustomCommandLine("nuget")>] Nuget of string
Expand All @@ -121,7 +183,13 @@ type UpdateArgs =
| Redirects
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
match this with
| Nuget(_) -> "Nuget package id"
| Version(_) -> "Allows to specify version of the package."
| Force -> "Forces the download and reinstallation of all packages."
| Hard -> "Replaces package references within project files even if they are not yet adhering to the Paket's conventions (and hence considered manually managed)."
| Redirects -> "Creates binding redirects for the NuGet packages."

type PackArgs =
| [<CustomCommandLine("output")>][<Mandatory>] Output of string
Expand All @@ -130,12 +198,90 @@ type PackArgs =
| [<CustomCommandLine("releaseNotes")>] ReleaseNotes of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mavnn could you please review the messages for this new command?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

match this with
| Output(_) -> "Output directory to put nupkgs."
| BuildConfig(_) -> "Optionally specify build configuration that should be packaged (defaults to Release)."
| Version(_) -> "Specify version of the package."
| ReleaseNotes(_) -> "Specify relase notes for the package."

type PushArgs =
| [<CustomCommandLine("url")>][<Mandatory>] Url of string
| [<CustomCommandLine("file")>][<Mandatory>] FileName of string
| [<CustomCommandLine("apikey")>] ApiKey of string
with
interface IArgParserTemplate with
member __.Usage = ""
member this.Usage =
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mavnn - and the same here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good here too

match this with
| Url(_) -> "Url of the Nuget feed."
| FileName(_) -> "Path to the package."
| ApiKey(_) -> "Optionally specify your API key on the command line. Otherwise uses the value of the `nugetkey` environment variable."

let cmdLineSyntax (parser:UnionArgParser<_>) commandName =
"$ paket " + commandName + " " + parser.PrintCommandLineSyntax()

let cmdLineUsageMessage (command : Command) parser =
System.Text.StringBuilder()
.Append("Paket ")
.AppendLine(command.Name)
.AppendLine()
.AppendLine((command :> IArgParserTemplate).Usage)
.AppendLine()
.Append(cmdLineSyntax parser command.Name)
.ToString()

let markdown (command : Command) (additionalText : string) =
let replace (pattern : string) (replacement : string) input =
System.Text.RegularExpressions.Regex.Replace(input, pattern, replacement)

let syntaxAndOptions (parser : UnionArgParser<_>) =
let options =
parser.Usage()
|> replace @"\s\t--help.*" ""
|> replace @"\t([-\w \[\]|\/\?<>\.]+):" (System.Environment.NewLine + @" `$1`:")

let syntax = cmdLineSyntax parser command.Name
syntax, options

let getSyntax = function
| Add -> syntaxAndOptions (UnionArgParser.Create<AddArgs>())
| Config -> syntaxAndOptions (UnionArgParser.Create<ConfigArgs>())
| ConvertFromNuget -> syntaxAndOptions (UnionArgParser.Create<ConvertFromNugetArgs>())
| FindRefs -> syntaxAndOptions (UnionArgParser.Create<FindRefsArgs>())
| Init -> syntaxAndOptions (UnionArgParser.Create<InitArgs>())
| AutoRestore -> syntaxAndOptions (UnionArgParser.Create<AutoRestoreArgs>())
| Install -> syntaxAndOptions (UnionArgParser.Create<InstallArgs>())
| Outdated -> syntaxAndOptions (UnionArgParser.Create<OutdatedArgs>())
| Remove -> syntaxAndOptions (UnionArgParser.Create<RemoveArgs>())
| Restore -> syntaxAndOptions (UnionArgParser.Create<RestoreArgs>())
| Simplify -> syntaxAndOptions (UnionArgParser.Create<SimplifyArgs>())
| Update -> syntaxAndOptions (UnionArgParser.Create<UpdateArgs>())
| Pack -> syntaxAndOptions (UnionArgParser.Create<PackArgs>())
| Push -> syntaxAndOptions (UnionArgParser.Create<PushArgs>())


let replaceLinks (text : string) =
text
.Replace("paket.dependencies file","[`paket.dependencies` file](dependencies-file.html)")
.Replace("paket.lock file","[`paket.lock` file](lock-file.html)")
.Replace("paket.template files","[`paket.template` files](template-files.html)")
.Replace("paket.references files","[`paket.references` files](references-files.html)")
.Replace("paket.references file","[`paket.references` file](references-files.html)")

let syntax, options = getSyntax command

System.Text.StringBuilder()
.Append("# paket ")
.AppendLine(command.Name)
.AppendLine()
.AppendLine((command :> IArgParserTemplate).Usage)
.AppendLine()
.AppendLine(" [lang=batchfile]")
.Append(" ")
.AppendLine(syntax)
.AppendLine()
.AppendLine("Options:")
.AppendLine(options)
.Append(additionalText)
.ToString()
|> replaceLinks
Loading