whosonfirst / deprecated-go-whosonfirst-clone

Tools and libraries for cloning (not syncing) Who's on First data to your local machine.
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

Exit with some non-zero exit status when things aren't stellar #7

Closed heffergm closed 8 years ago

heffergm commented 8 years ago

In the below example, blah is non-existent. I'd expect some non-zero exit status if the requested file I'm requesting be loaded doesn't exist.

grant: ~/.../whosonfirst/go-whosonfirst-clone (master)$ ./bin/wof-clone-metafiles -dest /tmp blah
[wof-clone-metafiles] 23:06:05.620065 [error] Failed to read /Users/grant/repos/whosonfirst/go-whosonfirst-clone/blah, because open /Users/grant/repos/whosonfirst/go-whosonfirst-clone/blah: no such file or directory
[wof-clone-metafiles] 23:06:05.622269 [info] processed 0 files (ok: 0 error: 0 skipped: 0) in 0.002046 seconds
grant: ~/.../whosonfirst/go-whosonfirst-clone (master)$ echo $?
0
thisisaaronland commented 8 years ago

Two things:

1) The code has retry hooks at the end on the grounds that AWS/S3 is expected to fail at least once during a batch:

https://github.com/whosonfirst/go-whosonfirst-clone/blob/master/clone.go#L162-L168

2) But yes, it should behave list a proper CLI tool assuming the retry code fails

thisisaaronland commented 8 years ago

Okay, so there is this:

https://github.com/whosonfirst/go-whosonfirst-clone/compare/exit

Can you rebuild from the exit branch and let me know if this accomplishes what you're after? Specifically you can pass the wof-clone-metafile binary a -strict flag which will exit 1 if anything fails.

heffergm commented 8 years ago

Perfect, you rock.

grant: ~/.../whosonfirst/go-whosonfirst-clone (exit)$ ./bin/wof-clone-metafiles -strict -dest ../data/ ../blah
[wof-clone-metafiles] 13:58:07.841550 [error] Failed to read /Users/grant/repos/whosonfirst/blah, because open /Users/grant/repos/whosonfirst/blah: no such file or directory
[wof-clone-metafiles] 13:58:07.841699 [error] failed to clone ../blah, because open /Users/grant/repos/whosonfirst/blah: no such file or directory
grant: ~/.../whosonfirst/go-whosonfirst-clone (exit)$ echo $?
1
thisisaaronland commented 8 years ago

Okay, I will merge with master just as soon as I finish commenting on this other issue ;-)

tasteful muzak plays

thisisaaronland commented 8 years ago

Now in master.