File tree Expand file tree Collapse file tree 2 files changed +21
-2
lines changed
Expand file tree Collapse file tree 2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ npm install --save httpsnippet
2323
2424```
2525
26- Usage: httpsnippet [options] <file >
26+ Usage: httpsnippet [options] <files ... >
2727
2828 Options:
2929
@@ -32,6 +32,7 @@ npm install --save httpsnippet
3232 -t, --target <target> target output
3333 -c, --client [client] target client library
3434 -o, --output <directory> write output to directory
35+ -x, --extra [{"optionKey": "optionValue"}] provide extra options for the target/client
3536
3637```
3738
@@ -63,6 +64,13 @@ snippets/
6364└── endpoint-3.js
6465```
6566
67+ provide extra options:
68+
69+ ``` shell
70+ httpsnippet example.json --target http --output ./snippets -x ' {"autoHost": false, "autoContentLength": false}'
71+ ```
72+
73+
6674## API
6775
6876### HTTPSnippet(source)
Original file line number Diff line number Diff line change 1717 . option ( '-t, --target <target>' , 'target output' )
1818 . option ( '-c, --client [client]' , 'target client library' )
1919 . option ( '-o, --output <directory>' , 'write output to directory' )
20+ . option ( '-x, --extra [{"optionKey": "optionValue"}]' , 'provide extra options for the target/client' )
2021 . parse ( process . argv )
2122
2223if ( ! cmd . args . length || ! cmd . target ) {
2324 cmd . help ( )
2425}
2526
27+ let extraOptions
28+ if ( cmd . extra ) {
29+ try {
30+ extraOptions = JSON . parse ( cmd . extra )
31+ } catch ( e ) {
32+ console . error ( '%s failed to parse options %s (should be JSON)' , chalk . red ( '✖' ) , chalk . cyan . bold ( cmd . extra ) )
33+ process . exit ( )
34+ }
35+ }
36+
2637let dir
2738if ( cmd . output ) {
2839 dir = path . resolve ( cmd . output )
@@ -53,7 +64,7 @@ cmd.args.forEach(function (fileName) {
5364 } )
5465
5566 . then ( function ( snippet ) {
56- return snippet . convert ( cmd . target , cmd . client )
67+ return snippet . convert ( cmd . target , cmd . client , extraOptions )
5768 } )
5869
5970 . then ( function ( output ) {
You can’t perform that action at this time.
0 commit comments