Commit Graph

2405 Commits

Author SHA1 Message Date
Wolfgang Bumiller
ab8a6120ca api-macro: started with some more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-23 15:55:18 +01:00
Wolfgang Bumiller
176e208caf api-macro: add consts for defaults
Not sure how we want to actually handle default values yet.
For now we need to figure out what "feels best".
This adds default values as publicly available consts so
they can be accessed from anywhere as
`API_METHOD_<METHOD_NAME>_PARAM_DEFAULT_<PARAM_NAME>`.
This is quite a handful to type, but I'm not sure how to
make this better.

Within the function body we also have the
`api_get_default!(param_name)` macro which is more
convenient, but not available outside the `#[api]` tagged
function.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-23 09:15:54 +01:00
Fabian Grünbichler
6a21867d87 api-macro: explicitly enable syn's visit-mut feature
otherwise the build fails because the module is not visible

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-23 08:04:26 +01:00
Wolfgang Bumiller
f5d15872f4 api-macro: add api_get_default!() macro
When writing an #[api] function, one can now access default
values by parameter name (see test_default_option in
tests/options.rs):

    #[api(...)]
    pub fn func(value: Option<isize>) {
        println!(
            "value: {}",
            value.unwrap_or(api_get_default!("value")),
        );
    }

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 15:49:34 +01:00
Wolfgang Bumiller
8beec0d6e6 api-macro: tests for optional non-Option parameters
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 12:08:38 +01:00
Wolfgang Bumiller
83b6d082db api-macro: allow optional types without Option<T>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 12:08:10 +01:00
Wolfgang Bumiller
832dd021c2 bump proxmox crate to 0.1.19-1
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 10:00:50 +01:00
Wolfgang Bumiller
2065bcb136 bump api-macro to 0.1.5
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 09:58:02 +01:00
Dominik Csapak
d1bfafe157 make cli format a bit saner
this looks more like pve/pmg cli tools now
without double the empty lines

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-19 09:50:47 +01:00
Wolfgang Bumiller
d84f563d5b buildsys: drop format check in check target
rename 'checkfmt' target to 'fmt'
there's no "apply formatting" target anymore now, this has
to be done manually to not do this by accident

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-16 12:21:14 +01:00
Wolfgang Bumiller
c5c82abc7d api-macro: cleanup: warnings
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 13:50:39 +01:00
Wolfgang Bumiller
8e1ace59b1 api-macro: cleanup: don't use try_fold for a Vec
`collect()` uses `FromIterator` which is also implemented
for `Result<Vec, Err>` from `Result<Item, Err>` doing the
same thing.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 13:37:59 +01:00
Wolfgang Bumiller
2edd8da965 api-macro: add integer limit test cases
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 12:02:32 +01:00
Wolfgang Bumiller
723500dbfc api-macro: include default minimum/maximum for integer types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:59:08 +01:00
Wolfgang Bumiller
f4e88aab6c api-macro: replace unreachable with a panic
(we're not running into this, but ran into an unreachable in
`syn` during development, and I needed to make sure it's not
one of ours...)

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:56:48 +01:00
Wolfgang Bumiller
dc4ec65723 api-macro: correctly infer newtype types
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 11:10:22 +01:00
Wolfgang Bumiller
67949bf8f0 api-macro: factor handle_struct differently
Don't assume an empty object schema for all cases as
newtypes shouldn't use an object schema at all actually!

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-03-06 10:53:59 +01:00
Fabian Grünbichler
0e9eb37ea0 build: add -upload target
requires 'dcmd' from devscripts to extract binary package file names
from .changes file

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2020-03-03 11:50:31 +01:00
Dietmar Maurer
5c188c7340 Revert "add proxmox/src/sys/linux/fs.rs"
This reverts the previous commit 21b9321cf8.

Turn out we only need this for pxar, so this will get moved into the pxar crate.
2020-03-02 14:07:35 +01:00
Dietmar Maurer
21b9321cf8 add proxmox/src/sys/linux/fs.rs 2020-03-02 13:59:39 +01:00
Dietmar Maurer
bff0791307 bump rust-proxmox version 0.1.18-1 2020-03-02 12:48:31 +01:00
Dietmar Maurer
59bd5bcad6 src/api/section_config.rs: moved SectionConfig from proxmox-backup 2020-03-02 10:56:40 +01:00
Dietmar Maurer
18b53d0fa6 fix typo in doc comment 2020-02-28 10:10:35 +01:00
Dietmar Maurer
ccc4d2ddd4 bump rust-proxmox version 0.1.17-1 2020-02-28 10:08:24 +01:00
Dietmar Maurer
9d9ab22128 text_table.rs: fix max column width when displaying without header 2020-02-28 10:05:59 +01:00
Dietmar Maurer
a5083b9028 text_table.rs: add table padding 2020-02-28 09:45:31 +01:00
Dietmar Maurer
c1eeaf7612 text_table.rs: fix column seperator for ascii tables 2020-02-28 09:29:04 +01:00
Wolfgang Bumiller
ece152d42c bump proxmox to 0.1.16
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:12:28 +01:00
Wolfgang Bumiller
d7be7df86c bump proxmox-api-macro to 0.1.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:10:40 +01:00
Wolfgang Bumiller
dd8ccd80d9 api-macro: make API_{RETURN,PARAMETER}_SCHEMA_... public
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-02-27 13:08:59 +01:00
Dietmar Maurer
739b3e2721 bump rust-proxmox version to 0.1.15-1 2020-02-27 12:36:57 +01:00
Dietmar Maurer
a21fd499f6 proxmox/src/api/cli/text_table.rs: new helpers to read output format from environment 2020-02-27 12:34:46 +01:00
Dietmar Maurer
e3c1104ed3 bump rust-proxmox version to 0.1.14-1 2020-02-27 11:17:38 +01:00
Dietmar Maurer
875f00bb85 proxmox/src/api/cli/text_table.rs - format_object: use column_config header
Also right_align Value column if all properthies are right_aligned.
2020-02-27 11:10:02 +01:00
Dietmar Maurer
43fd868a6d proxmox/src/api/cli/text_table.rs: implement sort by multiple columns
Also implement sort order flag and column header property.
2020-02-27 10:01:30 +01:00
Dietmar Maurer
f62fe221f0 src/api/schema.rs - verify_json_object: improve error message 2020-01-31 09:00:51 +01:00
Dietmar Maurer
c4311d4f11 bump librust-proxmox version to 0.1.13-1 2020-01-31 08:04:30 +01:00
Dietmar Maurer
afa61fafb0 src/api/cli/text_table.rs: use new sys::linux::tty::stdout_terminal_size 2020-01-31 08:02:06 +01:00
Dietmar Maurer
4d21db36fe src/sys/linux/tty.rs: add tty helpers 2020-01-31 07:58:48 +01:00
Christian Ebner
98708e346d fix typos in doc comments.
Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
2020-01-31 07:03:33 +01:00
Dietmar Maurer
db316a1fd8 bump rust-proxmox version to 0.1.12-1 2020-01-31 06:53:33 +01:00
Dietmar Maurer
af7d6cd045 src/api/cli/text_table.rs: only call TIOCGWINSZ on terminals 2020-01-30 18:25:43 +01:00
Dietmar Maurer
9976f04357 src/api/cli/text_table.rs - TableFormatOptions: allow to add single column configs 2020-01-30 18:18:26 +01:00
Wolfgang Bumiller
f7019c4231 bump version to 0.1.11
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:46:28 +01:00
Wolfgang Bumiller
468bc44c68 proxmox: bump api-macro version dependency
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:45:51 +01:00
Wolfgang Bumiller
39566afb15 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:37:26 +01:00
Wolfgang Bumiller
db741bfb81 bump api-macro to 0.1.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:35:28 +01:00
Wolfgang Bumiller
eadffcfc16 expose parameter schema as API_PARAMETER_SCHEMA_<methodname>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:32:22 +01:00
Wolfgang Bumiller
2c7b786cef expose return schema as API_RETURN_SCHEMA_<methodname>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2020-01-30 12:28:19 +01:00
Dietmar Maurer
9a281f6150 bump rust-proxmox version to 0.1.10-1 2020-01-30 11:47:06 +01:00