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
Markbind help: update output to match userguide #550
Conversation
index.js
Outdated
.option('-p, --port <port>', 'port for server to listen on (Default is 8080)') | ||
.option('-s, --site-config <file>', 'specify the site config file (default: site.json)') | ||
.option('-p <port>, --port <port>', 'port for server to listen on (Default is 8080)') | ||
.option('-s <file>, --site-config <file>', 'specify the site config file (default: site.json)') |
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.
This change breaks the options: -p
and -s
do not have an effect, and the long options --port
and --site-config
are not recognised.
The reason is because the library we are using for the CLI, commander.js, parses the first argument to .option
as a list of flags:
The
flags
string should contain both the short and long flags, separated by comma, a pipe or space.
I don't think we can make this specific change without breaking the CLI.
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.
Hi @Xenonym, thanks for the explanation. I should have tested it myself. I got it now. Then I will remove my modification.
index.js
Outdated
@@ -172,6 +172,7 @@ program | |||
|
|||
program | |||
.command('build [root] [output]') | |||
.option('<output>', 'put the generated files in the specified directory') |
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.
As with earlier, commander.js expects a list of flags as the first argument to .option()
. Passing in anything else doesn't seem to have meaningful results.
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.
Thanks for pointing out again. I will remove this line as well. For this issue, is there any other parts that i have missed which is supposed to be done?
@JYL123 comparing between the user guide and the output of
|
@Xenonym excellent review, good work. 👍 @damithc just checking, how much of the matching were you looking for when you created #535? Were you expecting a close match like this:
|
It's better to be as close as possible, right? For example, use the same notation for options |
The description in the CLI is actually parsed by commander.js to determine what arguments the command takes. I don't think we can change it without breaking the commands. |
I see. I don't mind if the user guide is changed to match the format used by CLI, if that format is good enough. In the user guide, I was trying to follow the format used by Git documentation. |
Hi, thanks for clarifying this issue. is it okay that I make the following changes:
Please correct me if anything is wrong or not appropriate. Thanks in advance. |
It looks like |
Thanks prof. I see. It makes sense. Then I think the user guide is good. I will undo my change to the user guide, namely keep the user guide as follows:
And change the descriptions in |
Got it. I'll leave the senior devs to make the final decision w.r.t. the exact format to follow. |
Is that actually possible with commander.js? I don't see a way of specifying the description for the compulsory arguments... Also, I am in favour of such a format:
Basically, the help description in the CLI should be as short as possible (which is what we have currently). The user guide should also have the short description, but then it will be followed by the details for the command. For example, the help description for
But the user guide should contain the single sentence summary + additional description of what it does:
|
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.
- For
markbind build
, update the user guide's description of--baseUrl
to match what you have here (e.g. in the user guide, it mentions "with the give" rather than "with the given"). - For
markbind serve
, update the description of the options inindex.js
to the first statement in the user guide. - Please add the following code, such that when
markbind --help
is invoked, it says "Usage: markbind " instead of "Usage: index ":
diff --git a/index.js b/index.js
index 33ccb4f..8bd0007 100755
--- a/index.js
+++ b/index.js
@@ -29,6 +29,7 @@ function printHeader() {
}
program
+ .name('markbind')
.allowUnknownOption()
.usage(' <command>');
docs/userGuide/cliCommands.md
Outdated
@@ -65,7 +69,9 @@ MarkBind Command Line Interface (CLI) can be run in the following ways: | |||
|
|||
**Format:** `markbind init [<OPTIONS>]` | |||
|
|||
**Description:** Initializes a directory into a MarkBind site by creating a skeleton structure for the website which includes a `index.md` and a `site.json`. | |||
**Description:** Init a markbind website project. |
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.
markbind -> MarkBind. (this should also be modified in index.js
)
docs/userGuide/cliCommands.md
Outdated
@@ -82,7 +88,9 @@ MarkBind Command Line Interface (CLI) can be run in the following ways: | |||
|
|||
**Format:** `markbind serve [<OPTIONS>]` | |||
|
|||
**Description:** Does the following steps: | |||
**Description:** Build then serve a website from a directory. |
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.
Build then serve a website from a directory. (this should also be modified in index.js
)
While it is true that MarkBind does build the site into _site/
, techincally, they don't really have to do that (i.e. we could have built the files in a temporary hidden directory rather than modifying _site/
, because markbind serve
is not really supposed to do building anyway). Therefore, I stroke off the "Build then" portion because that is too much unnecessary details.
The steps that follow (i.e. the "Does the following steps:" part) can stay however.
index.js
Outdated
|
||
program | ||
.command('deploy') | ||
.description('deploy the site to the repo\'s Github pages') |
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.
Github -> GitHub. site -> website. (this should also be modified in cliCommands.md
)
There are two other issues that I have spotted.
|
@yamgent Thanks for the review! |
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.
- We don't use merge commits inside PR (we want to keep the repo history as clean as possible). So the merge commit
Merge branch 'master' into update-help-to-match-userguide
shouldn't appear in this PR.
A rebase should be done to resolve conflicts instead. See this guide for details.
docs/userGuide/cliCommands.md
Outdated
@@ -69,7 +69,7 @@ Deploys the site to the repo's Github pages by pushing everything in the generat | |||
|
|||
**Format:** `markbind init [<OPTIONS>]` | |||
|
|||
**Description:** Init a markbind website project. | |||
**Description:** Init a Markbind website project. |
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.
The B needs to be capitalized as well, that is how we brand our project. (i.e. MarkBind
, not Markbind
)
docs/userGuide/cliCommands.md
Outdated
* `-o, --one-page [file]`<br> | ||
Render and serve only a single page from your website.<br> | ||
{{ icon_example }} `--one-page guide/index.md` | ||
* `-p [port]`, `--port [port]`<br> |
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.
You got it the wrong way round. :P
Things like [root]
are the optional arguments (users can omit root
when using markbind serve
). They should be wrapped with []
.
Things like <port>
are the compulsory arguments (users must specify a port number when using -p
). They should be wrapped with <>
.
Most of the commands and options have this issue as well, please do rectify them, thanks!
What is the purpose of this pull request? (put "X" next to an item, remove the rest)
• [X ] Enhancement to an existing feature
What is the rationale for this request?
Fixes #535
What changes did you make? (Give an overview)
Update
index.js
command descriptions to match the updates in user guide. The modified command overview is as follows from terminal:Is there anything you'd like reviewers to focus on?
Testing instructions:
Run
markbind -h
from terminal