Skip to content

Commit

Permalink
close #6 add a cli
Browse files Browse the repository at this point in the history
  • Loading branch information
manland committed Jan 13, 2017
1 parent c91b3fd commit e6df7de
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 15 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

> npm install j2ts
_`j2ts` use [java-class-parser](https://github.com/villadora/java-class-parser) ==> you need to have `javap` in your path._
_`j2ts` use `javap` to extract meta-data of your java classes. So, you need to have it in on your system (installed with jdk)._

## Js Api

Expand All @@ -22,14 +22,23 @@ j2ts(path, options)

return a promise with an array of {name: className, str: resultTs}.

## Development
## CLI

> npm run test
After install, add a script in your `package.json` :

```json
{
"scripts": {
"j2ts": "j2ts -f \"[glob]\" -d \"path\""
}
}
```

## Roadmap
To see all options run `j2ts --help`

* add a cli
* use package to write file in directories (not flattened)
## Development

> npm run test
## Contribution

Expand Down
21 changes: 21 additions & 0 deletions cli
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env node

var argv = require('yargs')
.usage('Usage: $0 -f [glob] -g [bool] -d [path]')
.demandOption(['filepath'])
.describe('filepath', 'A glob pattern to load java .class')
.alias('f', 'filepath')
.boolean('generateHasClass')
.default('generateHasClass', false)
.describe('generateHasClass', 'If true generated code is ts class based, else is interface')
.alias('g', 'generateHasClass')
.default('dest', null)
.describe('dest', 'Where to put generated file, if not set, generated code will be printed in console.')
.alias('d', 'dest')
.argv;

require('./index')(argv.filepath, {generateHasClass: argv.generateHasClass, dest: argv.dest}).then(res => {
if(argv.dest === null) {
res.forEach(clazz => console.log(clazz.str));
}
});

0 comments on commit e6df7de

Please sign in to comment.