Closed 0x-r4bbit closed 9 years ago
I'm actually a big fan of this as it follows the unix standard, and upon seeing everything output to the screen, most users will simply
$ clog [options] > changelog.md
What's TBD though is should clog
automatically detect previous changelogs? Only if specified in a .clog.toml
? Speaking of the .clog.toml
that also makes even easier, as you can already specify a file. So if this option is present in the .clog.toml
use it, if not, print to stdout
.
What's TBD though is should clog automatically detect previous changelogs?
Is that needed when clogs simply always prepends?
Speaking of the .clog.toml that also makes even easier, as you can already specify a file. So if this option is present in the .clog.toml use it, if not, print to stdout.
Right, I think .clog.toml
is the first place to check. Then provided options. Then defaults.
Is that needed when clogs simply always prepends?
I agree, if the path given (via > changelog.md
, or in .clog.toml
) points to an already existing file, then it's going to prepend anyway. Otherwise, it's going to create a file. I don't think clog needs to automatically detect changelogs if the default output will be to stdout.
I agree. I'd propose the following:
clog -o changelog.md
and that file exists, prepend and output to the fileclog -o changelog.md
and the file doesn't exist, create it and output to a file.clog.toml
check for existance, prepend if needed unless there is a -o
which overrides the .clog.toml
.clog.toml
and no -o
option, output to stdout
This is actually how clog
already functions, minus number 4 which is an easy addition. But should be talked about with #55
Unfortunately, we can't check if clog > mychangelog.md
exists because the > mychangelog.md
is interpreted by the shell, not clog
.
Unfortunately, we can't check if clog > mychangelog.md exists because the > mychangelog.md is interpreted by the shell, not clog.
Yes sorry, my bad. Obviously if the user uses >
then they know they are taking the entire output of clog and overwriting whatever might already exist in mychangelog.md
. But yes, :+1: to what you propose.
@kbknapp
Unfortunately, we can't check if clog > mychangelog.md exists because the > mychangelog.md is interpreted by the shell, not clog.
How do other UNIX command handle that case? git log > logs
also creates a file logs if it doesn't exist. ... Ah but it doesn't prepend if it exists...
Maybe we should just assume that the user knows how to use >
and >>
operators?
Maybe we should just assume that the user knows how to use > and >> operators?
That's what I'd recommend :+1: (and hope they don't try &>
:P )
@kbknapp this can easily be part of the developer guide documentation.
Maybe we should just assume that the user knows how to use > and >> operators?
Well yes, see my previous comment. As @kbknapp says, you can't do anything otherwise because >
is a shell construct.
If you want to prepend, best use something like:
$ clog > mychangelog.md | cat - mychangelog.md > /tmp/temp && mv /tmp/temp mychangelog.md
Of course, you should just use -o
for clog, but for other things you can use that provided you don't have anything important in /tmp/temp
.
Currently, clog creates a markdown file by default. As discussed in https://github.com/thoughtram/clog/issues/57, I think it'd make sense if writers could be swapped out.
This raises my next question: Unix commands usually write to stdout by default. If we implement a writer abstraction, so we can plug more into clog, we shouldn't prefer one over the other. Which brings me to the point, that it might be better if
clog
writes to stdout by default.Of course, this adds the complexity that you always have to provide a writer option in case you don't want to write to stdout, but this is how most/all UNIX commands work.
Thoughts on this?