Skip to content

Commit

Permalink
docs: update
Browse files Browse the repository at this point in the history
  • Loading branch information
thekiba committed Feb 11, 2024
1 parent c784072 commit 90fc50a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Then do:
npx tlb example.tlb
```

It will create a file called `example.tlb.ts` with the following code:
It will create a file called `example.ts` with the following code:
```typescript
export interface A {
readonly kind: 'A';
Expand Down Expand Up @@ -60,7 +60,7 @@ Also you can use the tool from inside JS or TS code.

```typescript
import { generateCode } from "@ton-community/tlb-codegen"
generateCode('example.tlb', 'example.tlb.ts', "typescript")
generateCode('example.tlb', 'example.ts', "typescript")
```


Expand Down
21 changes: 18 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,21 @@ import { generateCode } from './src/main';

const cli = meow(`
Usage
$ tlbgen <tlbpath>
$ tlb <tlbpath>
Options
--output, -o Output file, defult = tlbpath + ".ts"
--output, -o Output file, default = tlbpath with .ts extension e.g. ./path/to/file.tlb -> ./path/to/file.ts
--language, -l Programming language result. Supported languages: ["typescript"]. Default: "typescript"
Examples
$ tlb ./path/to/file.tlb
> Output: ./path/to/file.ts
$ tlb -o ./path/to/output.ts ./path/to/file.tlb
> Output: ./path/to/output.ts
$ tlb -l typescript ./path/to/file.tlb
> Output: ./path/to/file.ts
`, {
flags: {
output: {
Expand All @@ -25,7 +35,12 @@ const cli = meow(`

let input = cli.input.at(0)
if (input) {
let output = input + '.ts'
if (input.match(/\.tlb$/) == null) {
console.error('Input file must have .tlb extension')
process.exit(1)
}

let output = input.replace('.tlb', '.ts')
if (cli.flags.output) {
output = cli.flags.output;
}
Expand Down

0 comments on commit 90fc50a

Please sign in to comment.