From 53a9802ab2600597df4e8a9c37399e9139f5379a Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 15 Jul 2021 11:43:34 -0500 Subject: [PATCH] chore(derive): Ensure license is recorded for subcommand --- clap_derive/src/derives/subcommand.rs | 13 +++++++++++++ clap_derive/tests/ui/enum_variant_not_args.rs | 9 +++++++++ clap_derive/tests/ui/enum_variant_not_args.stderr | 7 +++++++ clap_derive/tests/ui/flatten_on_subcommand.rs | 10 ++++++++++ clap_derive/tests/ui/flatten_on_subcommand.stderr | 7 +++++++ 5 files changed, 46 insertions(+) create mode 100644 clap_derive/tests/ui/enum_variant_not_args.rs create mode 100644 clap_derive/tests/ui/enum_variant_not_args.stderr create mode 100644 clap_derive/tests/ui/flatten_on_subcommand.rs create mode 100644 clap_derive/tests/ui/flatten_on_subcommand.stderr diff --git a/clap_derive/src/derives/subcommand.rs b/clap_derive/src/derives/subcommand.rs index b4a955ff..8d73ce61 100644 --- a/clap_derive/src/derives/subcommand.rs +++ b/clap_derive/src/derives/subcommand.rs @@ -1,3 +1,16 @@ +// Copyright 2018 Guillaume Pinot (@TeXitoi) , +// Kevin Knapp (@kbknapp) , and +// Andrew Hobden (@hoverbear) +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. +// +// This work was derived from Structopt (https://github.com/TeXitoi/structopt) +// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the +// MIT/Apache 2.0 license. use crate::{ attrs::{Attrs, Kind, Name, DEFAULT_CASING, DEFAULT_ENV_CASING}, derives::args, diff --git a/clap_derive/tests/ui/enum_variant_not_args.rs b/clap_derive/tests/ui/enum_variant_not_args.rs new file mode 100644 index 00000000..8628b925 --- /dev/null +++ b/clap_derive/tests/ui/enum_variant_not_args.rs @@ -0,0 +1,9 @@ +#[derive(clap::Clap)] +enum Opt { + Sub(SubCmd), +} + +#[derive(clap::Clap)] +enum SubCmd {} + +fn main() {} diff --git a/clap_derive/tests/ui/enum_variant_not_args.stderr b/clap_derive/tests/ui/enum_variant_not_args.stderr new file mode 100644 index 00000000..f1a9b207 --- /dev/null +++ b/clap_derive/tests/ui/enum_variant_not_args.stderr @@ -0,0 +1,7 @@ +error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied + --> $DIR/enum_variant_not_args.rs:3:9 + | +3 | Sub(SubCmd), + | ^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` + | + = note: required by `augment_args` diff --git a/clap_derive/tests/ui/flatten_on_subcommand.rs b/clap_derive/tests/ui/flatten_on_subcommand.rs new file mode 100644 index 00000000..ad7cd5a0 --- /dev/null +++ b/clap_derive/tests/ui/flatten_on_subcommand.rs @@ -0,0 +1,10 @@ +#[derive(clap::Clap)] +struct Opt { + #[clap(flatten)] + sub: SubCmd, +} + +#[derive(clap::Clap)] +enum SubCmd {} + +fn main() {} diff --git a/clap_derive/tests/ui/flatten_on_subcommand.stderr b/clap_derive/tests/ui/flatten_on_subcommand.stderr new file mode 100644 index 00000000..cc753951 --- /dev/null +++ b/clap_derive/tests/ui/flatten_on_subcommand.stderr @@ -0,0 +1,7 @@ +error[E0277]: the trait bound `SubCmd: clap::Args` is not satisfied + --> $DIR/flatten_on_subcommand.rs:3:12 + | +3 | #[clap(flatten)] + | ^^^^^^^ the trait `clap::Args` is not implemented for `SubCmd` + | + = note: required by `augment_args`