Commit Graph

132 Commits

Author SHA1 Message Date
Sebastian Thiel
c28413321b Switch to serde to v1.0 2017-09-24 14:51:51 +02:00
Sebastian Thiel
1323d0dccb fix(tests): use new serde map implementation
No fun, this one.
2017-02-04 13:03:42 +01:00
Sebastian Thiel
7a611c39aa Adapt to changed Map interface 2017-02-04 11:52:42 +01:00
Sebastian Thiel
26f57948a6 chore(cli): one step closer to getting it compiled 2017-02-03 09:20:01 +01:00
Sebastian Thiel
1756d7dec4 chore(cli): fix error handling 2017-02-03 09:01:30 +01:00
Greg Dallavalle
8f47126103 Fix typo Requst->Request 2017-01-12 12:33:33 -06:00
Sebastian Thiel
e7721ce53b chore(cleanup): remove workaround marker
... and some left-over comments.

The workaround code is actually more readable than the previous version,
so it may as well stay.

Fixes #109
2016-07-17 13:56:25 +02:00
Sebastian Thiel
bed46ba241 fix(test): work with latest serde
`cargo test` will work now.
We now use the latest serde once again, which should
make everything better.
2016-05-20 18:40:26 +02:00
Sebastian Thiel
3e2216c445 chore(serde-up): use features for cli-dependency
That way, we respect the API features when pulling it in
via the CLI. Also make it compatible to the latest serde-json
version.
2016-05-20 16:40:44 +02:00
Sebastian Thiel
065cfdd22f fix(lib): use hyper Bearer header style
Considering we kind-of hardcoded this authentication type anyway,
we now use the Auth-types provided by hyper 0.8.

The incentive here was the compiler telling us that there the
yup-oauth::Scheme type doesn't implement the hyper::authorization::Scheme
anymore, even though that clearly was the case. Also it couldn't be
reproduced in yup-oauth itself.

This will need some work to get correct again, so this is just a crude
patch to make it work again.
2016-04-10 13:01:18 +02:00
Sebastian Thiel
9e8a047ebf fix(cli): compatibility with serde 0.6
0.7 has a weird assertion error that might have happened
if files get too large.
2016-04-10 12:59:59 +02:00
Sebastian Thiel
be0faf0e1d chore(serde): upgrade to 0.7
Desired feature: ignore unknown fields, which is now on by default.
2016-02-27 12:30:09 +01:00
Sebastian Thiel
a2c6b58d5b fix(versionup): use latest oauth2 lib
It enables using std::time::Duration natively
2016-01-30 14:03:15 +01:00
Sebastian Thiel
b54acb7c96 fix(rustup): use std::Thread::sleep
However, in sibling libraries, we still use time::Duration, which
now is a part of std::time::Duration.
These should be adjusted, to make the usage of
sleep(Duration::from_millis(d.num_milliseconds() as u64)) into sleep(d)
2016-01-29 18:56:58 +01:00
Curtis McEnroe
61e74d99a2 Fix impl of hyper::net::NetworkStream 2015-11-29 17:55:35 -05:00
Erick Tryzelaar
8179f3bf89 fix(cmn): get cmn compiling on nightly rust
Closes #131
2015-10-18 11:29:34 -07:00
Sebastian Thiel
8dab8c0124 fix(serde): update to latest serde/rust 2015-09-29 11:28:34 +02:00
Sebastian Thiel
8ab4fd0bd4 fix(serde-up): update to serde 0.5.0
Serde move all json code into a separate crate that we are now using
as well.
2015-08-08 10:55:21 +02:00
Sebastian Thiel
d0491a4950 fix(hyper-up): work with hyper v0.6.0
Currently the latter actually fails to link on OSX, and requires a local
override with [this fix](https://goo.gl/OTExmN).
2015-06-26 15:49:30 +02:00
Sebastian Thiel
2ad8d887cd fix(api): minor fixes
* Mime crate must be used in the same version hyper uses
* made attempted move a borrow
2015-06-19 11:41:29 +02:00
Sebastian Thiel
5483e32832 fix(api): expanded header implementation
Now it compiles to the point where `Mime` appears as duplicate type,
for some reason.
2015-06-19 11:34:57 +02:00
Sebastian Thiel
b0a41c4e78 fix(api): first big step towards syntex
Even though there is a bug that caues {} to be used in stead of
(),
when exanding macros, which causes syntax errors that we have to
workaround, it's not a real issue.

What's happening additionally is missing hyper macros, which
now have to be expanded manually. Shouldn't be a problem,
pretty-printing when compiling is made for just that ;).

No, it's sad that `include!()` works so badly, it makes
using serde so difficult ... it's no fun i must say.

Just for stable ... I am not sure if it is worth it."
2015-06-18 22:51:17 +02:00
Sebastian Thiel
ca36dbc505 feat(config): improved structure setter code
We save about 30% of CLI code just because we offload the work of
settings structures into serde, building a generic `json::Value` to
contain all the data, and then let serde do the deserialization for us.

All we need for that is some information we let the generator provide
and translate it into the runtime.

Closes #111
2015-05-13 08:45:57 +02:00
Sebastian Thiel
d0b69af413 refactor(config):OK version of json value setter
However, we don't set the correct field names yet, and are lacking
a remapping of CLI field names to struct field names before any
testing makes sense.
2015-05-13 07:51:08 +02:00
Sebastian Thiel
464394af22 refactor(config): handle recursive mut json values
* recurively drill down a mutable, recursive enumeration, without borrow
  checker issues. The obvious solution doesn't work, but should.
  Stackoverflow ?
* infrastructure to set actual value, with support for ararys, pods and
  hashmaps
2015-05-12 19:48:37 +02:00
Sebastian Thiel
f83dff672b refactor(config): bring in all required field data
Previously we only knew the type as string, now we have enums and
additional type information, like whether or not it's a POD.

However, borrow-checker doesn't like the current code, will need more
work.
2015-05-12 12:17:36 +02:00
Sebastian Thiel
a2dd71451d feat(config): basis for simplified value setting
Previously we would set static structures manully, using complex cases
and utility functions. Now we setup the foundation to allow setting
a generic `json::value::Value` instead, which can later be deserialized
into the target structure.

Related to #111
2015-05-12 11:17:42 +02:00
Sebastian Thiel
ee84fefb4a fix(rustup): deal with rustc lifetime issue
Related to #109
2015-05-11 10:56:36 +02:00
Sebastian Thiel
e86e55cae7 imp(API): improved display of BadRequest
Previously you would only see "BadRequest ... " without the information
that would actually help you to understand what the cause of the issue
is.
Now we will print all the information we have, accordingly, which
greatly improves usability.

Closes #103
[skip ci]
2015-05-09 19:15:16 +02:00
Sebastian Thiel
5894c8163a imp(CLI): remove null in pretty-printed json
Without all that clutter, it's so much more enjoyable to read the
output.

The implementation is based on a suggestion of @erickt, which is
converts into a json::Value (able to represent any json structure),
on which the filtering is applied.

If we should ever implement pretty-printing in json-tools, we might
still consider using these capabilities instead, as we would avoid
building potentially large datastructures, all we would need is
a sufficiently large destination buffer which is a single alloc and
a consecutive region in memory.

Closes #102
[skip ci]
2015-05-08 19:12:45 +02:00
Sebastian Thiel
3fe2732a01 fix(compat): upgrade to hyper v0.4.0
It was basically just a find-and-replace to adapt to the changed names
of Error and Result types.
2015-05-08 11:52:28 +02:00
Sebastian Thiel
2485343caa refactor(CLI): use arg_enum! clap-rs macro
That way, we get a better (case-insensitive) implementation of `FromStr`
which reduces the amount of code we have to maintain.

Closes #101
[skip ci]
2015-05-06 11:58:45 +02:00
Sebastian Thiel
96415d17ca feat(CLI): did you mean for struct values
* functionality is cursor-aware, and fixes the actual string the user
  passed in. That way, it is made very clear how the suggested value
  is to be used.
* it's a known weakness of the implementation that it operates on a
  flattened list of field names, and thus may make nonsensical
  suggestions.
* added punctuation to all errors

Fixes #67
[skip ci]
2015-05-02 14:07:28 +02:00
Sebastian Thiel
75b80de3c6 feat(CLI): -u <mode> <file> parsing
* As `possible_values()` applies to all arguments, we cannot use it
  anymore but have to check the UploadProtocol type ourselves.
  Besides that, switching to the latest `clap` simplified our lives
  a little.
* ajusted docs to not enforce using `-r` all the time

Fixes #92
[skip ci]
2015-05-01 20:00:25 +02:00
Sebastian Thiel
c346645fc9 fix(API): let delegate forget uploaded urls
When uploading using the resumable protocol, we are now telling the
delegate to forget the previously stored URL after successful upload.
Previously it would have tried to return such a URL and thus made
the system retry uploading a file that was already uploaded.

Fixes #85
[skip ci]
2015-05-01 16:24:31 +02:00
Sebastian Thiel
94c821e09d fix(CLI): adjust JsonTokenStorage to yup-oauth
Signature of `set()` changed to return a `Result<(), _>` instead of
an `Option<_>`.

Related to https://github.com/Byron/yup-oauth2/issues/5
[skip ci]
2015-04-30 17:14:12 +02:00
Sebastian Thiel
2f200217f9 fix(CLI): unified error handling
* Use `Result` everywhere, instead of Option or tuples
* Properly handle error occurring after the dry-run. We do it in an
  extensible way, in case we need to do more than handle invalid output
  files at some point. Output files that could not be opened will now
  result in a nice error message with all the information we have.

Fixes #66
2015-04-30 16:31:49 +02:00
Sebastian Thiel
894b5b5ec7 feat(CLI): adjust to serde usage in yup-oauth
* More detailed error type for JsonTokenStorage
* removed all traces of rustc_serialize
* use pretty-printers everywhere to allow writing human-readable json
  files for secretes and for tokens

Fixes #93
2015-04-30 15:20:56 +02:00
Sebastian Thiel
4115d50ca7 fix(API): adjust to latest hyper header macros 2015-04-30 11:15:48 +02:00
Sebastian Thiel
d0ce221ba3 fix(clap):re-introduce UploadProtocol,fix CallType
* CallType now represents either Upload or Standard calls, whereas
  the Upload variant is represented by the UploadProtocol enum.
  That way it's clear what happens, and we don't mix orthogonal concepts
  in one enumeration just for convenience.

All tested APIs seem to build, verified

* upload
* download
* request structures
* parameters
* scopes
* config-dir
* debug[-auth]

Fixes #81
2015-04-30 10:20:02 +02:00
Sebastian Thiel
b039b38244 fix(clap): update docs and fix calltype handling
* mkdoc docs grammar is now hierarchical, making the command structure
  more obvious and easier to understand. It's a nice addition to the
  auto-generated, hierachical usage of clap.
* UploadProtocol enum is now CallType, to ease handling the different
  ways the Call has to be executed. It looks quite clean, even though
  combining upload protocols and the calltype is a bit hacky.
2015-04-30 10:05:55 +02:00
Sebastian Thiel
7a38f7e4d5 fix(clap): various fixes and improvements
* `--version` now includes the API revision we embody
  (using crate_version())
* Allow multiple scopes to be specified, instead of just one. Previously
  this was problemantic due to argument parsing of docopt being greedy.
  However, this also means we have to specify the `-r` flag for each
  invocation. See https://github.com/kbknapp/clap-rs/issues/89 .
* Adapted to new signature of `Arg::possible_values()` and used the
  previously orphaned `UploadProtocol` enum.
* Deduplicated code a little by adding the new `opt_values()` generator
  function.

 Related to #81
2015-04-30 09:03:11 +02:00
Sebastian Thiel
63e23dd48f fix(clap): print usage if command is missing
Also, fixed config-dir substitution in flag's help message
2015-04-29 22:08:47 +02:00
Sebastian Thiel
bac4e1a82f fix(clap): adjust option usage to changed API
Discovery API now builds and seems to work even ! More testing
will have to be done though to be sure.

Related #81
2015-04-29 21:04:50 +02:00
Sebastian Thiel
1aff3135d9 fix(clap): commit before un-using UploadProtocol
We will try to wait for https://github.com/kbknapp/clap-rs/issues/87
to allow us to use the enumeration instead of strings, as well as
an iterator, which will look more idiomatic in the end.
2015-04-29 17:16:50 +02:00
Sebastian Thiel
db4624b467 feat(clap): parse structure and build App
We are currently setting everything up at runtime, and manage to get
nearly all information into it, except for the more complex
`-u (simple|resumable) <file> <mime>` flag.

Fixes #87
Related to #81
2015-04-29 16:49:02 +02:00
Sebastian Thiel
8ac8d3b1cb fix(clap): generate command data structure
We do this in the hopes to circumvent a stack overflow.
This means we will setup the parser entirely at runtime, which actually
saves a little bit of code.
2015-04-29 10:56:10 +02:00
Sebastian Thiel
b6a48bdcd5 fix(CLI): request value cursor handling and docs
* now the cursor will only be set permanently if the -r flag is used in
  'cursor' mode. In 'cursor=value' mode, the cursor change doesn't
  persist among the flags. That way, one can easily distinguish
  between setting the cursor, and setting a field. However,
  '...sublevel.level=value' will still work as it did previously, yet
  the cursor change will not persist.
* Documentation was adjusted to represent the new cursor style.

Fixes #86
2015-04-26 07:58:59 +02:00
Sebastian Thiel
2f3b2d24ce fix(CLI): simple and resumable upload works
* fixed boundary syntax of multi-part message. Was --BOUNDARY, now is
  --BOUNDARY--
* Fixed ContentRange parsing and serialization. We actually managed
  to break it last time we tried to update it to match the Go
  implementation.
* fixed uploadType header parameter. It's based on chosen protocol and
  whether or not the method supports multipart operation for the given
  protocol.

Related to #76
2015-04-25 18:45:37 +02:00
Sebastian Thiel
a328942033 feat(API): improved error handling
We are now able to decode detailed errors and pass them on. This allows
the CLI to provide more useful error responses.
Additionally, the CLI will only print debug responses in --debug mode.

Fixes #82
2015-04-25 09:49:57 +02:00