| 1 |
<!doctype html> |
| 2 |
<body> |
| 3 |
<div id="output"></div> |
| 4 |
<script type="module"> |
| 5 |
// Import the ESM version of the yargs module: |
| 6 |
import parser from 'http://127.0.0.1:8080/browser.js'; |
| 7 |
|
| 8 |
// Grab argv from the URL's GET parameters: |
| 9 |
const match = window.location.href.match(/.*argv=(?<argv>[^&]*)&opts=(?<opts>.*)$/); |
| 10 |
const argv = decodeURIComponent(match.groups.argv); |
| 11 |
let opts = {} |
| 12 |
try { |
| 13 |
opts = JSON.parse(decodeURIComponent(match.groups.opts)) |
| 14 |
} catch (_err) {} |
| 15 |
|
| 16 |
// Run yargs parser in browser context: |
| 17 |
const parsed = parser(argv, opts); |
| 18 |
const output = document.getElementById("output"); |
| 19 |
output.innerHTML = JSON.stringify(parsed); |
| 20 |
</script> |
| 21 |
</body> |