Skip to content

Commit ed7f7c3

Browse files
committed
fix(cli) Adjusts CLI options and update README
Signed-off-by: Jerome Simeon <[email protected]>
1 parent 1c3f6cf commit ed7f7c3

File tree

8 files changed

+13903
-4636
lines changed

8 files changed

+13903
-4636
lines changed

package-lock.json

Lines changed: 13878 additions & 4582 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"devDependencies": {
3-
"@accordproject/concerto-core": "^0.82.3",
3+
"@accordproject/concerto-core": "^0.82.4",
44
"colors": "1.3.3",
55
"concurrently": "4.1.1",
66
"coveralls": "3.0.4",

packages/markdown-cicero/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"webpack-cli": "^3.3.5"
8080
},
8181
"dependencies": {
82-
"@accordproject/concerto-core": "^0.82.3",
82+
"@accordproject/concerto-core": "^0.82.4",
8383
"@accordproject/markdown-common": "0.7.2",
8484
"commonmark": "^0.29.0",
8585
"jsome": "2.5.0",

packages/markdown-cli/README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ The command-line is called `markus` and offers the following commands:
1616
markus <cmd> [args]
1717
1818
Commands:
19-
markus parse parse and transform sample markdown
20-
markus draft create markdown text from data
21-
markus normalize parse a sample markdown and re-create it
19+
markus parse parse and transform a sample markdown
20+
markus draft create markdown text from data
21+
markus normalize normalize a sample markdown (parse & redraft)
2222
2323
Options:
2424
--version Show version number [boolean]
@@ -33,23 +33,20 @@ The `parse` command lets you parse markdown and create a document object model f
3333
```
3434
markus parse
3535
36-
parse and transform sample markdown
36+
parse and transform a sample markdown
3737
3838
Options:
3939
--version Show version number [boolean]
4040
--verbose, -v verbose output [boolean] [default: false]
4141
--help Show help [boolean]
4242
--sample path to the markdown text [string]
4343
--output path to the output file [string]
44-
--roundtrip roundtrip [boolean] [default: false]
4544
--cicero further transform to CiceroMark [boolean] [default: false]
4645
--slate further transform to Slate DOM [boolean] [default: false]
4746
--html further transform to HTML [boolean] [default: false]
48-
--noWrap do not wrap variables as XML tags [boolean] [default: false]
49-
--noIndex do not index ordered lists [boolean] [default: false]
5047
```
5148

52-
### Generate text from data
49+
### Generate markdown from data
5350

5451
The `draft` command lets you take a document object model and generate markdown text from it.
5552

@@ -64,20 +61,21 @@ Options:
6461
--help Show help [boolean]
6562
--data path to the data [string]
6663
--output path to the output file [string]
67-
--cicero further transform to CiceroMark [boolean] [default: false]
68-
--slate further transform to Slate DOM [boolean] [default: false]
69-
--noWrap do not wrap variables as XML tags [boolean] [default: false]
64+
--cicero input data is a CiceroMark DOM [boolean] [default: false]
65+
--slate input data is a Slate DOM [boolean] [default: false]
66+
--noWrap do not wrap CiceroMark variables as XML tags
67+
[boolean] [default: false]
7068
--noIndex do not index ordered lists [boolean] [default: false]
7169
```
7270

73-
### Re-generate text
71+
### Normalize the markdown
7472

75-
The `normalize` command lets you parse markdown and re-generate it after parsing.
73+
The `normalize` command lets you parse markdown and re-draft it from its document object model.
7674

7775
```
7876
markus normalize
7977
80-
parse a sample markdown and re-create it
78+
normalize a sample markdown (parse & redraft)
8179
8280
Options:
8381
--version Show version number [boolean]

packages/markdown-cli/index.js

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ require('yargs')
2424
.demandCommand(1, '# Please specify a command')
2525
.recommendCommands()
2626
.strict()
27-
.command('parse', 'parse and transform sample markdown', (yargs) => {
27+
.command('parse', 'parse and transform a sample markdown', (yargs) => {
2828
yargs.option('sample', {
2929
describe: 'path to the markdown text',
3030
type: 'string'
@@ -33,11 +33,6 @@ require('yargs')
3333
describe: 'path to the output file',
3434
type: 'string'
3535
});
36-
yargs.option('roundtrip', {
37-
describe: 'roundtrip',
38-
type: 'boolean',
39-
default: false
40-
});
4136
yargs.option('cicero', {
4237
describe: 'further transform to CiceroMark',
4338
type: 'boolean',
@@ -53,16 +48,6 @@ require('yargs')
5348
type: 'boolean',
5449
default: false
5550
});
56-
yargs.option('noWrap', {
57-
describe: 'do not wrap variables as XML tags',
58-
type: 'boolean',
59-
default: false
60-
});
61-
yargs.option('noIndex', {
62-
describe: 'do not index ordered lists',
63-
type: 'boolean',
64-
default: false
65-
});
6651
yargs.option('verbose', {
6752
describe: 'verbose output',
6853
type: 'boolean',
@@ -76,12 +61,9 @@ require('yargs')
7661
try {
7762
argv = Commands.validateParseArgs(argv);
7863
const options = {};
79-
options.roundtrip = argv.roundtrip;
8064
options.cicero = argv.cicero;
8165
options.slate = argv.slate;
8266
options.html = argv.html;
83-
options.noWrap = argv.noWrap;
84-
options.noIndex = argv.noIndex;
8567
options.verbose = argv.verbose;
8668
return Commands.parse(argv.sample, argv.output, options)
8769
.then((result) => {
@@ -105,17 +87,17 @@ require('yargs')
10587
type: 'string'
10688
});
10789
yargs.option('cicero', {
108-
describe: 'further transform to CiceroMark',
90+
describe: 'input data is a CiceroMark DOM',
10991
type: 'boolean',
11092
default: false
11193
});
11294
yargs.option('slate', {
113-
describe: 'further transform to Slate DOM',
95+
describe: 'input data is a Slate DOM',
11496
type: 'boolean',
11597
default: false
11698
});
11799
yargs.option('noWrap', {
118-
describe: 'do not wrap variables as XML tags',
100+
describe: 'do not wrap CiceroMark variables as XML tags',
119101
type: 'boolean',
120102
default: false
121103
});
@@ -154,7 +136,7 @@ require('yargs')
154136
return;
155137
}
156138
})
157-
.command('normalize', 'normalize markdown in a sample (parse & draft)', (yargs) => {
139+
.command('normalize', 'normalize a sample markdown (parse & redraft)', (yargs) => {
158140
yargs.option('sample', {
159141
describe: 'path to the markdown text',
160142
type: 'string'
@@ -190,7 +172,7 @@ require('yargs')
190172
});
191173
}, (argv) => {
192174
if (argv.verbose) {
193-
Logger.info(`parse and re-create sample ${argv.sample} markdown`);
175+
Logger.info(`normalize ${argv.sample} markdown`);
194176
}
195177

196178
try {

packages/markdown-cli/lib/Commands.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,13 @@ class Commands {
7777
* @param {boolean} [options.cicero] whether to further transform for Cicero
7878
* @param {boolean} [options.slate] whether to further transform for Slate
7979
* @param {boolean} [options.html] whether to further transform for HTML
80-
* @param {boolean} [options.noWrap] whether to avoid wrapping Cicero variables in XML tags
81-
* @param {boolean} [options.noIndex] do not index ordered list (i.e., use 1. everywhere)
8280
* @param {boolean} [options.verbose] verbose output
8381
* @returns {object} Promise to the result of parsing
8482
*/
8583
static parse(samplePath, outputPath, options) {
86-
const { cicero, slate, html, noWrap, noIndex, verbose } = options;
84+
const { cicero, slate, html, verbose } = options;
8785
const commonOptions = {};
8886
commonOptions.tagInfo = true;
89-
commonOptions.noIndex = noIndex ? true : false;
9087

9188
const commonMark = new CommonMarkTransformer(commonOptions);
9289
const ciceroMark = new CiceroMarkTransformer();
@@ -166,15 +163,14 @@ class Commands {
166163
* @returns {object} Promise to the result of parsing
167164
*/
168165
static draft(dataPath, outputPath, options) {
169-
const { roundtrip, cicero, slate, html, noWrap, noIndex, verbose } = options;
166+
const { cicero, slate, noWrap, noIndex, verbose } = options;
170167
const commonOptions = {};
171168
commonOptions.tagInfo = true;
172169
commonOptions.noIndex = noIndex ? true : false;
173170

174171
const commonMark = new CommonMarkTransformer(commonOptions);
175172
const ciceroMark = new CiceroMarkTransformer();
176173
const slateMark = new SlateTransformer();
177-
const htmlMark = new HtmlTransformer();
178174

179175
let result = JSON.parse(Fs.readFileSync(dataPath, 'utf8'));
180176
if (cicero) {
@@ -198,8 +194,6 @@ class Commands {
198194
Logger.info('=== CommonMark ===');
199195
Logger.info(JSON.stringify(result, null, 4));
200196
}
201-
} else if (html) {
202-
throw new Error('Cannot roundtrip from HTML');
203197
}
204198
result = commonMark.toMarkdown(result);
205199
if (outputPath) {
@@ -239,15 +233,14 @@ class Commands {
239233
* @returns {object} Promise to the result of parsing
240234
*/
241235
static normalize(samplePath, outputPath, options) {
242-
const { roundtrip, cicero, slate, html, noWrap, noIndex, verbose } = options;
236+
const { cicero, slate, noWrap, noIndex, verbose } = options;
243237
const commonOptions = {};
244238
commonOptions.tagInfo = true;
245239
commonOptions.noIndex = noIndex ? true : false;
246240

247241
const commonMark = new CommonMarkTransformer(commonOptions);
248242
const ciceroMark = new CiceroMarkTransformer();
249243
const slateMark = new SlateTransformer();
250-
const htmlMark = new HtmlTransformer();
251244

252245
const markdownText = Fs.readFileSync(samplePath, 'utf8');
253246
let result = commonMark.fromMarkdown(markdownText, 'json');
@@ -297,8 +290,6 @@ class Commands {
297290
Logger.info('=== CommonMark ===');
298291
Logger.info(JSON.stringify(result, null, 4));
299292
}
300-
} else if (html) {
301-
throw new Error('Cannot roundtrip from HTML');
302293
}
303294
result = commonMark.toMarkdown(result);
304295
if (outputPath) {

packages/markdown-cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"tsd-jsdoc": "^2.3.0"
5353
},
5454
"dependencies": {
55-
"@accordproject/concerto-core": "^0.82.3",
55+
"@accordproject/concerto-core": "^0.82.4",
5656
"@accordproject/markdown-common": "0.7.2",
5757
"@accordproject/markdown-cicero": "0.7.2",
5858
"@accordproject/markdown-slate": "0.7.2",

packages/markdown-common/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"webpack-cli": "^3.3.5"
8080
},
8181
"dependencies": {
82-
"@accordproject/concerto-core": "^0.82.3",
82+
"@accordproject/concerto-core": "^0.82.4",
8383
"commonmark": "^0.29.0",
8484
"jsome": "2.5.0",
8585
"sax": "^1.2.4",

0 commit comments

Comments
 (0)