Skip to content

Commit

Permalink
docs: update CLI docs with feature related to #240 and querySelector …
Browse files Browse the repository at this point in the history
…option
  • Loading branch information
FanJups committed Jul 29, 2024
1 parent 2988304 commit cc89864
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 11 deletions.
41 changes: 30 additions & 11 deletions README.cli.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
# Command Line Interface

```shell
let targetElement_000 = document.querySelector(`:root > body`);
let targetElement_001 = document.querySelector(`:root > body`);


let div_000 = document.createElement('div');
let text_000 = document.createTextNode(`I am a `);
div_000.appendChild(text_000);
let div_001 = document.createElement('div');
let text_001 = document.createTextNode(`I am a `);
div_001.appendChild(text_001);

let strong_000 = document.createElement('strong');
let text_001 = document.createTextNode(`tea pot`);
strong_000.appendChild(text_001);
div_000.appendChild(strong_000);
targetElement_000.appendChild(div_000);
let strong_001 = document.createElement('strong');
let text_002 = document.createTextNode(`tea pot`);
strong_001.appendChild(text_002);
div_001.appendChild(strong_001);
targetElement_001.appendChild(div_001);
```

---

`jsgenerator` has several options that can be used in a console here is an example of use below

```text
Usage: jsgenerator [-htV] [-e=<extension>] [--inline-pattern=<inlinePattern>]
Usage: jsgenerator [-chtV] [-qs] [-e=<extension>]
[--inline-pattern=<inlinePattern>]
[-k=<variableDeclaration>] [--path-pattern=<pathPattern>]
[-s=<targetElementSelector>]
[--stdin-pattern=<stdinPattern>]
[--variable-name-generation-strategy=<builtinVariableNameStra
tegy>] [-i=<inlineContents>...]... [<paths>...]
Translating files, stdin or inline from HTML to JS
[<paths>...] file paths to translate content, parsed as HTML
-c, --comment optional comments
-e, --ext=<extension> output files' extension
-h, --help Show this help message and exit.
-i, --inline=<inlineContents>...
Expand All @@ -38,6 +40,23 @@ Translating files, stdin or inline from HTML to JS
variable declaration keyword
--path-pattern=<pathPattern>
pattern for path-based output filenames
-qs, --query-selector
What the browser renders depends on whether "document.
querySelector(':root > body')" is added to the
output. If added, the browser will render the
output successfully, it is useful for debugging
purpose,
to verify that the js output matches what the
html input does.
If not, if the user tries to run the output as
it is then the browser will not be able to render,
it will show a blank page.
So, it depends on what the user wants to do with
the output.
"https://jsfiddle.net/", "https://codepen.
io/pen/" and Browser Console help to give a quick
feedback.
-s, --selector=<targetElementSelector>
Target element selector
--stdin-pattern=<stdinPattern>
Expand All @@ -46,4 +65,4 @@ Translating files, stdin or inline from HTML to JS
-V, --version Print version information and exit.
--variable-name-generation-strategy=<builtinVariableNameStrategy>
Variable names generation strategy
```
```
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ mvn --also-make --projects jsgenerator-cli clean spring-boot:run -Dspring-boot.r

# For example:
mvn --also-make --projects :jsgenerator-cli clean spring-boot:run -Dspring-boot.run.arguments="--tty --inline '<div>I am a <strong>tea pot</strong></div>'"

# It's also possible to create the jar first
mvn clean package

# then run the following commands and replace {version} by the current one (0.0.1-SNAPSHOT at this time)
java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar # java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar --help
java -jar jsgenerator-cli/target/jsgenerator-cli-{version}.jar --tty --inline '<div>I am a <strong>tea pot</strong></div>'
```

## Packaging
Expand Down

0 comments on commit cc89864

Please sign in to comment.