denysdovhan / textr-cli

Command line interface for Textr
MIT License
11 stars 0 forks source link

CLI options #1

Open denysdovhan opened 8 years ago

denysdovhan commented 8 years ago

Discussion about base options

@iamstarkov and @shuvalov-anton, please leave your suggestions bellow. If you don't mind, let's move the discussion about CLI here.

Transformers [Done #2]

Few -t or --transforms options:

$ textr -t typographic-single-spaces -t typographic-quotes

-t or --transforms as list of transformers:

$ textr -t typographic-single-spaces,typographic-quotes

-t or --transforms throught equal sign:

$ text --transforms=typographic-single-spaces,typographic-quotes

Input [Done #2]

Read from stdin:

$ cat foo.md | textr

Read from file:

$ textr foo.md

Output [Done #2]

Write into stdout:

$ smth | textr > bar.md

Write into file using --out-file or -o flags:

$ textr in.md -o out.md

Locale [Done #2]

Set local using -l and --locale:

textr foo.md -l ru -o bar.md

Watch [Done #3]

--watch and -w:

$ textr input.md -w

Diff

Output diff instead of result:

$ textr --diff

Config

.textrrc with config. This file should be connected automatically. But user should be able to redefine it with -c option (should works like a .vimrc, '.babelrc`, etc).

.textrrc example:

{
    "options": {
        "locale": 'en-us',
        ...
    },
    "watch": true,
    "transformers": [...transformers]
}

Ref to https://github.com/shuvalov-anton/textr/issues/1

iamstarkov commented 8 years ago

I love Babel api with 'in', 'out' params and with 'preset' feature

Cheers, Vladimir Starkov, iamstarkov.com

denysdovhan commented 8 years ago

@iamstarkov I can add them, in addition to textr [in] [out].

iamstarkov commented 8 years ago

btw can we just use Babel as framework now when it is general build tool?

Cheers, Vladimir Starkov, iamstarkov.com

denysdovhan commented 8 years ago

What do you mean when you say "use Babel as framework"?

A commented 8 years ago

Here is a --cycle option, that creates new tf instance on every cycle. Do we realy need that option?

I've used the -c option just to benchmark textr. I think, now it's redundant. Feel free to kill it :D

A commented 8 years ago

What do you mean when you say "use Babel as framework"?

@iamstarkov Is it really useful for us? Are you suggest to make textr plugin for babel? Or did you meant smth else?

denysdovhan commented 8 years ago

@shuvalov-anton okay, I'll remove -c.

iamstarkov commented 8 years ago

I mean Babel is general build system from now on, so maybe we can use Babel with textr presets

Cheers, Vladimir Starkov, iamstarkov.com

denysdovhan commented 8 years ago

Are you suggest to make textr plugin for babel?

I don't think that's a good idea. For example, typography-ellipses will break spread operator. Or are you talking about presets for text files.

iamstarkov commented 8 years ago

I didn't intend to use it for js projects but if it's possible to use Babel cli infrastructure then it will be cool

Cheers, Vladimir Starkov, iamstarkov.com

denysdovhan commented 8 years ago

@iamstarkov I still don't understand what you want. Can you explain with example?

iamstarkov commented 8 years ago

yep, but only tomorrow

Cheers, Vladimir Starkov, iamstarkov.com

A commented 8 years ago

I got. But IMHO babel things isn't very useful for small CLI project. I want to take a look on it, but I guess it's about the other.

iamstarkov commented 8 years ago

I'll also take a look tomorrow and hope It will work out

Cheers, Vladimir Starkov, iamstarkov.com

iamstarkov commented 8 years ago

i take a look at babel plugins examples and it seems like the only purpose is javascript files

iamstarkov commented 8 years ago

so yeah babel is not for us

iamstarkov commented 8 years ago

but I definitely like its API with --out-file | -o, --out-dir | -d,--watch | -w and piping files $ babel --out-file script-compiled.js < script.js

I think we can learn from them

iamstarkov commented 8 years ago
$ textr -t typographic-single-spaces,typographic-quotes

is it possible to make it without coma? like this:

$ textr -t typographic-single-spaces typographic-quotes
denysdovhan commented 8 years ago

I definitely like its API with --out-file | -o, --out-dir | -d, --watch | -w

About -o: I thought use second arg as output file, like this:

$ textr input.md output.md

So, if we use -o, we should remove ability to output into second arg.

About -d: It could be useful for few files. I'll try to implement this (but it conflicts with --diff and -d flags)

About -w: Looks cool. Added to draft.

denysdovhan commented 8 years ago

is it possible to make it without coma?

It can be cofused with arguments. For example:

$ cat input | textr -t typographic-single-spaces typographic-quotes output.md

Above, output.md could be resolved as transformer.

But, we can use it, like this:

$ cat input | textr -t typographic-single-spaces -t typographic-quotes output.md
iamstarkov commented 8 years ago

it's just a wish

Cheers, Vladimir Starkov, iamstarkov.com

A commented 8 years ago

is it possible to make it without coma?

It's confusing. -1

But, we can use it, like this:

$ cat input | textr -t typographic-single-spaces -t typographic-quotes output.md

+1

iamstarkov commented 8 years ago

okay ⚡️

Cheers, Vladimir Starkov, iamstarkov.com

On 03 Nov 2015, at 9:31 AM, Shuvalov Anton notifications@github.com wrote:

is it possible to make it without coma? It's confusing. -1

But, we can use it, like this:

$ cat input | textr -t typographic-single-spaces -t typographic-quotes output.md +1

— Reply to this email directly or view it on GitHub.

denysdovhan commented 8 years ago

What are you thinking about -o|--out-file? Should I implement it, ot better to leave output file as second argument?:

$ textr input.md output.md

or

$ textr input.md -o output.md

P.S: If there isn't second argument, then result will be witten into stdout.

iamstarkov commented 8 years ago

I would love explicit output param with default stdout

A commented 8 years ago

i prefer -o

denysdovhan commented 8 years ago

okay, I'm gonna implement -o param

iamstarkov commented 8 years ago

btw, thank you for taking initiative over cli :clap:

denysdovhan commented 8 years ago

I've finished first implementation with tests. Take a look here: https://github.com/denysdovhan/textr-cli/tree/dev

--diff, --watch and -o aren't implemented yet, but I'm in progress.

Also, we've forgot about --locale flag.

iamstarkov commented 8 years ago

btw, @shuvalov-anton locale was bothering me and i think it shouldnt be 'en' by default and if not defined then textr plugins should not do anything impicitly. what do you think?

denysdovhan commented 8 years ago

btw, thank you for taking initiative over cli :clap:

@iamstarkov that's bcoz i'm gonna use textr, but I need cli. It's profitable to me, at first ;)

denysdovhan commented 8 years ago

I've finished --locale|-l and --out-file|-o. Now, I'm gonna to release 0.1.0.

denysdovhan commented 8 years ago

Take a look #2.

denysdovhan commented 8 years ago

How about adding --config|-c options for loading configuration from json file, like a .eslintrc or .babelrc? Because it's a little bit difficult to write in teminal:

textr some-article.md -t typographic-quotes,typographic-single-spaces,typographic-ellipses,typographic-em-dashes -o output.md -w
A commented 8 years ago

LGTM :D

denysdovhan commented 8 years ago

But what's better loading textrrc, or give opportunity to chose any of json files? I think second case would be better.

A commented 8 years ago

I think, good case is specify .textrrc in your dotfiles. This file should be connected automatically. But you should be able to redefine it w/ -c option. Vim works same.

denysdovhan commented 8 years ago

Yep, I've understood. It will be better.