Crate json_arg

source ·
Expand description

CLIs (especially those designed to be called by automation) often take structured data as inputs. This ends up creating a ton of boilerplate where a CLI arg is declared as a PathBuf and then is quickly opened, read from and deserialized with some serde format crate. This crate provides two newtype wrappers (Serde and SerdeFile) that can deserialize any Serde-compatible arguments with no extra effort.

Structs

  • Deserialize the argument as JSON
  • Inline JSON string. The argument provided by the caller is the raw JSON string (and the caller must consequently deal with shell quoting ahead-of-time).
  • Argument that represents a serialized file. The argument provided by the caller is the path to the file that is deserialized immediately on load. The original path is preserved and accessible with SerdeFile::path
  • Deserialize the argument as TOML

Traits

Type Definitions