Skip to content

Commit

Permalink
fix/version-flags (#57)
Browse files Browse the repository at this point in the history
* Fixed documentation for version usage, and bug with cli-arg package that incorrectly dealt with booleans

* removed console.log statement

* updated docs to reflect multiple interactions with version create
  • Loading branch information
gratcliff authored and erunion committed Aug 8, 2019
1 parent c75e117 commit e62d55c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 19 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ If you wish to see the raw output from our API in this response, supply the `--

#### Create a new version
```sh
rdme versions:create <version>
rdme versions:create <version> | --version={project-version}
```

##### Automating this process
Expand All @@ -114,14 +114,14 @@ If you wish to automate the process of creating a new project version, and not h
For example:

```sh
rdme versions:create <version> --fork={version-fork} --codename={version-name} --main --beta
rdme versions:create <version> | --version={project-version} --fork={version-fork} --main={boolean} --beta={boolean} --isPublic={boolean}
```

See `rdme versions:create --help` for a full list of flags.

#### Update a version
```sh
rdme versions:update <version>
rdme versions:update --version={project-version}
```

Like `versions:create`, if you wish to automate this process and not be blocked by CLI input, you can supply the necessary flags to this command. See `rdme versions:update --help` or [automating this process](#automating-this-process) for more information.
Expand All @@ -130,7 +130,7 @@ Like `versions:create`, if you wish to automate this process and not be blocked
You can remove a specific version from your project, as well as all of the attached specs

```sh
rdme versions:delete <version>
rdme versions:delete --version={project-version}
```

### Open your ReadMe project in your browser
Expand Down
16 changes: 9 additions & 7 deletions cmds/versions/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { prompt } = require('enquirer');
const promptOpts = require('../../lib/prompts');

exports.command = 'versions:create';
exports.usage = 'versions:create <version> [options]';
exports.usage = 'versions:create <version> | --version={project-version} [options]';
exports.description = 'Create a new version for your project.';
exports.category = 'versions';
exports.position = 2;
Expand Down Expand Up @@ -33,17 +33,17 @@ exports.args = [
},
{
name: 'main',
type: Boolean,
type: String,
description: 'Should this version be the primary (default) version for your project?',
},
{
name: 'beta',
type: Boolean,
type: String,
description: 'Is this version in beta?',
},
{
name: 'isPublic',
type: Boolean,
type: String,
description: 'Would you like to make this version public? Any primary version must be public.',
},
];
Expand Down Expand Up @@ -78,10 +78,12 @@ exports.run = async function(opts) {
json: {
version,
codename: codename || '',
is_stable: main || promptResponse.is_stable,
is_beta: beta || promptResponse.is_beta,
is_stable: main === 'true' || promptResponse.is_stable,
is_beta: beta === 'true' || promptResponse.is_beta,
from: fork || promptResponse.from,
is_hidden: promptResponse.is_stable ? false : !(isPublic || promptResponse.is_hidden),
is_hidden: promptResponse.is_stable
? false
: !(isPublic === 'true' || promptResponse.is_hidden),
},
auth: { user: key },
};
Expand Down
2 changes: 1 addition & 1 deletion cmds/versions/delete.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const request = require('request-promise-native');
const config = require('config');

exports.command = 'versions:delete';
exports.usage = 'versions:delete <version> [options]';
exports.usage = 'versions:delete --version={project-version} [options]';
exports.description = 'Delete a version associated with your ReadMe project.';
exports.category = 'versions';
exports.position = 4;
Expand Down
16 changes: 9 additions & 7 deletions cmds/versions/update.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const { prompt } = require('enquirer');
const promptOpts = require('../../lib/prompts');

exports.command = 'versions:update';
exports.usage = 'versions:update <version> [options]';
exports.usage = 'versions:update --version={project-version} [options]';
exports.description = 'Update an existing version for your project.';
exports.category = 'versions';
exports.position = 3;
Expand All @@ -27,17 +27,17 @@ exports.args = [
},
{
name: 'main',
type: Boolean,
type: String,
description: 'Should this version be the primary (default) version for your project?',
},
{
name: 'beta',
type: Boolean,
type: String,
description: 'Is this version in beta?',
},
{
name: 'isPublic',
type: Boolean,
type: String,
description: 'Would you like to make this version public? Any primary version must be public.',
},
];
Expand Down Expand Up @@ -69,10 +69,12 @@ exports.run = async function(opts) {
json: {
codename: codename || '',
version: newVersion || promptResponse.newVersion,
is_stable: foundVersion.is_stable || main || promptResponse.is_stable,
is_beta: beta || promptResponse.is_beta,
is_stable: foundVersion.is_stable || main === 'true' || promptResponse.is_stable,
is_beta: beta === 'true' || promptResponse.is_beta,
is_deprecated: deprecated || promptResponse.is_deprecated,
is_hidden: promptResponse.is_stable ? false : !(isPublic || promptResponse.is_hidden),
is_hidden: promptResponse.is_stable
? false
: !(isPublic === 'true' || promptResponse.is_hidden),
},
auth: { user: key },
};
Expand Down

0 comments on commit e62d55c

Please sign in to comment.