Commit Graph

104 Commits

Author SHA1 Message Date
Sebastian Thiel
27fdd8ee0c fix(rustup): type-inference fails on empty vec
Previously this wasn't the case, as the type could be inferred by the
type of the parent-vector to extend.

Apparently this feature was removed, probably for good reason.
2015-06-21 17:55:46 +02:00
Sebastian Thiel
62db3ae87c fix(cli): add type annotation
It seems to be required when building with an older rustc version.
This did work in nightly, and just seems to be some sort of limiation
in stable.
2015-06-19 18:03:55 +02:00
Sebastian Thiel
a9e0be6583 fix(cli): work on stable
CLI was slightly adjusted to not use unstable features.
Fortunately, there is no serde magic happening, which allows
us to keep it simple without using a build script.
2015-06-19 12:55:00 +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
267868cea3 Merge branch 'master' into next 2015-05-18 10:49:24 +02:00
Sebastian Thiel
129fd38e00 imp(CLI): disallow empty values explicitly
[skip ci]
2015-05-18 10:19:38 +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
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
383595c44e docs(CLI): added Download information
That way, it's easy to obtain the respective precompiled binary, as
well as seeing the source-code.

Overall, it makes promoting the tools easier as the CLI docs can be
linked directly.

Closes #108
[skip ci]
2015-05-10 19:40:25 +02:00
Sebastian Thiel
fff466f6bc docs(CLI): after_help url for method scmds
That way, whenever the extended help of a method (e.g. apis get-rest)
is queried, you can easily jump to the online docs to get details about
required data-structures or parameters for instance.

[skip ci]
2015-05-09 14:36:40 +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
bbab1f2e38 refactor(CLI): use raw strings for argparser
That way, we should be save from contained '"' characters, and whatever
else.

Closes #100
2015-05-05 20:02:26 +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
89432cc646 fix(CLI): gate usage of upload_media_params
Previously the local stack variable would be used even though it
wasn't initialized as there were no upload flags. Now this only
happens if there are media params.

[skip ci]
2015-05-02 09:57:08 +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
153324ebcc fix(CLI): 'about()' text for main commands
It shows up in the help, and makes it easier to navigate the command
tree without bringing up the html documentation.

Fixes #95
[skip ci]
2015-04-30 17:30:45 +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
fac50418a7 fix(CLI): escape subcommand descriptions
Otherwise, we could have had invalid rust strings.

[skip ci]
2015-04-30 13:48:11 +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
feaa3a06ed fix(clap): handle apis without media upload
We are annotating the type of the optional protocols if that shall be
required.
2015-04-29 19:48:45 +02:00
Sebastian Thiel
02a4129662 fix(clap): call iter() directly
As IntoIter is only implemented for slices up a sice of 32.
DFAReporting though will reach 55, at least.

Also added dfareporting-cli code to show how stackoverflow issues can be
circumvented efficiently.
2015-04-29 19:32:04 +02:00
Sebastian Thiel
656fcae2b4 feat(clap): implement -u as good as possible
We can't have the `-u <mode> <file> <mime>` style yet, but
https://github.com/kbknapp/clap-rs/issues/88 might help with that
at some point.

Related to #92 and #81
2015-04-29 18:36:39 +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
b39bc3a9cd feat(clap): initial version of command generation
It compiles and works, even though there are many things we want to
improve.

One big question is how to define multi-arguments, like -u foo bar baz.
2015-04-28 19:34:24 +02:00
Sebastian Thiel
988d37f0df feat(clap): setup infrastructure
This allows us to setup clap and see if it compiles, which is the prime
goal of the current workflow step.

Related to #81
2015-04-28 16:33:16 +02:00
Sebastian Thiel
4f98fc175e docs(CLI): visual gap between cursor and kv
Previously, the space was barely visible, confusing even myself :).
Now it's clear, using 4 spaces, that there is a cursor invocation
followed by a key-value pair.
2015-04-27 16:14:34 +02:00
Sebastian Thiel
12743f543d docs(CLI): add link to general documentation
[skip ci]
2015-04-27 07:54:12 +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
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