Commit Graph

59 Commits

Author SHA1 Message Date
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
2ca0529297 fix(rustup): dc630d01e 2015-05-09
* Vec::add was removed ... which forces me to write 4 lines instead of
  one very readable one :(.
  Not everything is to the better here, even though I can imagine they
  did it to prevent people from thinking this is a cheap operation.

[skip ci]
2015-05-11 10:58:00 +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
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
ef63790422 refactor(CLI): better vector building
Instead of using multiple lines to add vectors up involving iterators,
I just add slices together. This should produce less, and possibly
faster machine code, with less ascii code.

Downloads tested with drive2, and are verified to be working !

Close #97
2015-05-06 11:04:19 +02:00
Sebastian Thiel
f1fe6bac01 refactor(CLI): move global params to runtime
Global params were repeated per method, even though they were global,
per API. Now they are kept in vectors and used at runtime, accordingly.
We save a little bit of code, have simple matches, and less repition.

It's unclear if this reduces the size of the binary though ... or the
compile times, as the extra loop is an extra loop after all ;).

Still need to test the download mode using drive1

Related to #97
[skip ci]
2015-05-05 21:44:27 +02:00
Sebastian Thiel
9274938f9f fix(CLI): completed list of parameter names
Previously the 'did-you-mean' functionality only knew the global
paramters, but not the method-local ones.
2015-05-05 20:46: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
bf6a2ba60c fix(CLI): handle repeated required strings
In a single case we wouldn't properly pass on string arguments that
were repeated. Now we handle them with a nice one-liner.

Fixes #96

[skip ci]
2015-05-01 15:22:59 +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
bd27046cc8 docs(clap): update STRUCT_FLAG and UPLOAD flags
* adjust documentation to resemble actual upload flag semantics. It was
  still using the one previously used in docopt.
* Make -m <mime-type> optional, defaulting to 'application/octet-stream'

Should have been fixed alongside of #81
2015-04-30 13:40: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
5320a48e68 fix(clap): tweaks to make youtube3 work
Mainly minor cleanup, and handling of generator branches that
didn't show up in smaller APIs that were used during the first steps.

related to #81
2015-04-29 21:59:06 +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
944e04bd12 docs(CLI): filled README.md
All possible documentation was added in a quality sufficient for
a first release. After all, everything there is is documented.

Fixes #50
2015-04-26 11:22:28 +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
0bb30da782 fix(CLI): use only one request structure
This works as we can just put all request-structure parsing to the top
of the function.
That way, we don't put the request struture twice.
2015-04-25 13:32:03 +02:00
Sebastian Thiel
be7ccb085c fix(CLI): set request value to call
Previously, even though the request was passed by reference, it was
copied and thus our changes never arrived in the call.

Now the API makes this clear by taking ownership, and the CLI code
sets the Request value lateron, explicitly.

Related to #76
2015-04-25 13:25:00 +02:00
Sebastian Thiel
6befdbc6fa fix(CLI): verified download works
* implement custom scopes - previously they could be set, but were
  ignored during the API call
* api-overrides are not yaml files for convenience. Existing ones were
  updated as needed.

Fixes #75
2015-04-25 11:35:39 +02:00
Sebastian Thiel
845a568b25 fix(CLI): response value json decoding
* updated all json API descriptions
* enabled 'pretty' printing of response structures. However, currently
  there is no way to get rid of all the NULL fields without external
  filtering
* all structure fields are now optional - there seems to be no way
  around it.

Fixes #73
2015-04-24 16:00:27 +02:00
Sebastian Thiel
e42f6fbedb feat(CLI): per-API-credentials with default
That way, we can provide better service, as CLIs that consume a lot of
quota can easily have their own app credentials, and with it, their
own quota.

The fallback will be a project that allows to use all possible
google APIs.

The user can always put in his own application secret to use his own
quota or even paid services.

Fixes #80
2015-04-24 10:52:43 +02:00
Sebastian Thiel
797f289886 fix(CLI): resolve generator issues
* exclude dataflow API - it doesn't have a single method as long as
  it's in B4. See https://github.com/Byron/google-apis-rs/issues/78
* assure ARRAY branch can be hit

Fixes #77
2015-04-22 11:41:50 +02:00
Sebastian Thiel
b830c1c6de feat(CLI): hashmap handling
* with native support for type conversion and error handling
* improved hash-map key-value parsing to at least state that it knows
  it's dealing with a hashmap. Error text is still not what it should
  be because we don't know at runtime (initially) what type we handle.

Fixes #68
Related to #77
2015-04-22 11:09:50 +02:00
Sebastian Thiel
c14ef9afc8 feat(CLI): repeated required args
* Seem to work for docopt, mkdocs and code itself
* mkdocs now show type of required params
* some code which deals with converting elements to their
  target types is totally untested right now.

Related to #77
2015-04-22 10:28:13 +02:00
Sebastian Thiel
03f35bd4f5 feat(CLI): --debug-auth flag
* Allow to see all authentication related communication, similar to
  --debug flag otherwise.
* fixed broken generator when handling request value parsing.

Fixes #70
2015-04-21 12:18:50 +02:00
Sebastian Thiel
159c65916f feat(CLI): --debug flag to output traffix
* If `--debug` is set, we will output all server communication to
  stderr. That way, we can compare our requests to what is expected by
  ush based on official docs.
* `discovery` now doesn't use the API key anymore - this is specified
   using a custom override.

Nice, we are totally ready to test and fix all API features.

Related to #70
2015-04-21 12:03:58 +02:00
Sebastian Thiel
f7740ad149 refactor(engine): request-value parsing;Default
* Default::default() optimized to use T::default() if possible
* deduplicated special type handling ('Count' strings -> int64)
* put request value parsing into own private function

Fixes #69
[skip ci]
2015-04-21 11:00:40 +02:00
Sebastian Thiel
fa278a99c7 fix(CLI): request value parsing compiles and inits
Therefore, you can now actually make the call and the program will not
crash due to uninitialized Options.

Fixes #64
2015-04-16 21:22:12 +02:00
Sebastian Thiel
bf22bef77a fix(CLI): struct access compiles ...
... but currently wouldn't run as we don't initialize the optional sub-
structures at all.
2015-04-16 19:53:15 +02:00
Sebastian Thiel
15b78cd1ff feat(CLI): struct value parsing
This works already for simple request values, but doens't generate
compiling code for structures with Parts in them.
Nonetheless, it's a big step towards finishing the overall issue.

Related to #64
2015-04-16 17:44:30 +02:00
Sebastian Thiel
4b87d909f2 fix(CLI): NULL default values instead of randoms
Instead of generating nonesense random values, we just map defaults
that represent the respective NULL value of a given type.
2015-04-15 18:29:21 +02:00
Sebastian Thiel
6119bfb762 feat(CLI): make respective uppload_call
Now we actually provide the information required to upload data in a
simple or resumable fashion.

Fixes #62
2015-04-15 18:16:56 +02:00
Sebastian Thiel
9eed4056e5 feat(CLI): upload flag parsing
We handle errors gracefully with costum types and minimal amount of
code. Unfortunately, Mime type parsing is very 'flexible', allowing
nonesense types to be passed easily.

Related to #62
2015-04-15 17:23:01 +02:00
Sebastian Thiel
306852d514 fix(CLI): alt-media handling in CLI+API-docs
* API-docs now adjust depending on where 'alt' is set (either as global
  parameter, or as method-parameter)
* CLI: download tracking now works for 'alt' as method-parameter
* CLI: global parameter remapping allows them to be named consistently,
  but map to the name required by the google API.

Fixes #61
2015-04-15 14:41:46 +02:00
Sebastian Thiel
36a7cb239a feat(CLI): global optional parameters+DL tracking
* set globally shared parameters (which includes 'alt')
* track if 'alt' is set to 'media' at runtime to do the right thing when
  outputting the result. There is still an issue to be fixed though

Related to #61
2015-04-15 12:12:39 +02:00
Sebastian Thiel
830529c40b fix(CLI): optional parameter default handling
Now we provide a matching default for each paramter, thus alleviating
the previous issue of unncecessary follow-up errors.
2015-04-15 11:27:48 +02:00
Sebastian Thiel
6ae6ee88a0 feat(CLI): parse method parameters and set them
It's implemented in a working fashion, except that the default value
is not currently set to something sensible, causing duplicate errors in
case the key-value syntax is wrong.

Related to #61
2015-04-15 11:02:23 +02:00
Sebastian Thiel
3f49f50ac2 feat(CLI):handle output json encoding and ostreams
* support for encoding response schemas to json
* support for simple downloads (without alt=media)

Fixes #63
2015-04-14 21:57:58 +02:00
Sebastian Thiel
c3a9f1e8e5 feat(CLI): interpret output arguments
For now we don't properly handle errors when opening files, but the
code is there.
Will panic in next commit.

Related to #63
2015-04-14 21:18:57 +02:00
Sebastian Thiel
76841da098 fix(CLI): optimze argument handling and conversion
* Thanks to a generic function, we save a lot of code within main.rs
* more effcient signature for ParseError

Fixes #65
2015-04-14 20:17:30 +02:00