blob: f5852a7407f083c218d6fe9c2a2e083764586590 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
//! ref: composer/vendor/symfony/console/Attribute/AsCommand.php
/// Service tag to autoconfigure commands.
///
/// PHP attribute: #[\Attribute(\Attribute::TARGET_CLASS)]
#[derive(Debug)]
pub struct AsCommand {
pub name: String,
pub description: Option<String>,
}
impl AsCommand {
pub fn new(
name: String,
description: Option<String>,
aliases: Vec<String>,
hidden: bool,
) -> Self {
let mut this = Self { name, description };
if !hidden && aliases.is_empty() {
return this;
}
let mut name: Vec<String> = this.name.split('|').map(|s| s.to_string()).collect();
name.extend(aliases);
if hidden && "" != name[0] {
name.insert(0, String::new());
}
this.name = name.join("|");
this
}
}
|