1cmd Main("cp") [
2 requires Sources
3 requires Dest | TargetDirectory
4] {
5 /// source files or directories to copy
6 arg Sources(0..-1) => List<Path> [
7 requires FileExists | DirExists
8 ]
9
10 /// destination file or directory (the last positional argument,
11 /// omitted when -t is used)
12 arg Dest(-1) => Path [
13 effects FileExists
14 excludes TargetDirectory
15 ]
16
17
18 /// treat DEST as a normal file, never as a directory; only valid
19 /// when exactly one source is given
20 opt NoTargetDirectory("T", "no-target-directory") => Bool [
21 excludes TargetDirectory
22 ]
23
24 /// copy all SOURCE arguments into DIRECTORY instead of using the
25 /// last positional as the destination
26 opt TargetDirectory("t", "target-directory") => Path [
27 requires DirExists
28 excludes NoTargetDirectory
29 ]
30
31 /// copy directories (and their contents) recursively
32 opt Recursive("r", "R", "recursive") => Bool
33
34 /// archive mode: preserve all attributes and copy recursively
35 /// (equivalent to -dR --preserve=all)
36 opt Archive("a", "archive") => Bool
37
38 /// hard link files instead of copying them
39 opt Link("l", "link") => Bool [
40 excludes SymbolicLink
41 ]
42
43 /// make symbolic links instead of copying
44 opt SymbolicLink("s", "symbolic-link") => Bool [
45 excludes Link
46 ]
47
48 /// copy only when SOURCE is newer than DEST, or DEST is missing;
49 /// UPDATE controls which files are replaced
50 opt Update("update") => "all" | "none" | "none-fail" | "older" [
51 @default("older")
52 ]
53
54 /// equivalent to --update=older
55 opt UpdateOlder("u") => Bool
56
57 /// (deprecated) silently skip existing destination files;
58 /// prefer --update=none instead
59 opt NoClobber("n", "no-clobber") => Bool
60
61 /// only copy file attributes, not file data
62 opt AttributesOnly("attributes-only") => Bool
63
64 /// copy contents of special files (e.g. device nodes) when recursive
65 opt CopyContents("copy-contents") => Bool [
66 requires Recursive
67 ]
68
69 /// use full source file name (rooted path) under the target DIRECTORY,
70 /// creating intermediate directories as needed
71 opt Parents("parents") => Bool [
72 requires TargetDirectory | Dest
73 ]
74
75 /// remove trailing slashes from each SOURCE argument before processing
76 opt StripTrailingSlashes("strip-trailing-slashes") => Bool
77
78
79 /// follow symbolic links listed on the command line in SOURCE
80 /// (command-line symlinks only; others are not followed)
81 opt FollowCliLinks("H") => Bool [
82 excludes Dereference
83 excludes NoDereference
84 ]
85
86 /// always follow symbolic links in SOURCE (dereference all)
87 opt Dereference("L", "dereference") => Bool [
88 excludes NoDereference
89 excludes FollowCliLinks
90 ]
91
92 /// never follow symbolic links in SOURCE; copy the symlink itself
93 opt NoDereference("P", "no-dereference") => Bool [
94 excludes Dereference
95 excludes FollowCliLinks
96 ]
97
98 /// follow existing symlinks to directories at the destination
99 opt KeepDirectorySymlink("keep-directory-symlink") => Bool
100
101
102 type FileAttributes => "mode" | "ownership" | "timestamps" | "links" | "context" | "xattr" | "all"
103
104 /// preserve the specified file attributes (default: mode, ownership,
105 /// timestamps); additional attrs: links, context, xattr, all
106 opt Preserve("preserve") => List<FileAttributes> [
107 @default(["mode", "ownership", "timestamps"])
108 ]
109
110 /// shorthand for --preserve=mode,ownership,timestamps
111 opt PreserveBasic("p") => Bool
112
113 /// do not preserve the specified attributes
114 opt NoPreserve("no-preserve") => List<FileAttributes>
115
116 type BackupKind => "none" | "off" | "numbered" | "t" | "existing" | "nil" | "simple" | "never"
117
118 /// make a backup of each existing destination file; CONTROL selects
119 /// the versioning scheme
120 opt Backup("backup") => BackupKind [
121 @default("existing")
122 ]
123
124 /// like --backup but always uses the simple scheme and takes no argument
125 opt BackupSimple("b") => Bool
126
127 /// override the default backup suffix (~)
128 opt Suffix("S", "suffix") => String
129
130 type BehaviourKind => "auto" | "always" | "never"
131
132 /// control copy-on-write / clone behaviour
133 opt Reflink("reflink") => BehaviourKind [
134 @default("auto")
135 ]
136
137 /// control creation of sparse files in the destination
138 opt Sparse("sparse") => BehaviourKind [
139 @default("auto")
140 ]
141
142 /// do not cross filesystem boundaries (stay on the same device)
143 opt OneFileSystem("x", "one-file-system") => Bool
144
145 /// remove each existing destination file before opening it
146 /// (contrast with --force, which removes only when open fails)
147 opt RemoveDestination("remove-destination") => Bool [
148 excludes Force
149 ]
150
151
152 /// if an existing destination file cannot be opened, remove it
153 /// and try again (ignored when -n is also used)
154 opt Force("f", "force") => Bool [
155 excludes RemoveDestination
156 ]
157
158 /// prompt before every overwrite
159 opt Interactive("i", "interactive") => Bool [
160 excludes NoClobber
161 ]
162
163 /// set the SELinux security context of the destination to the default type
164 opt SelinuxDefault("Z") => Bool [
165 excludes Context
166 ]
167
168 /// set the SELinux or SMACK security context of the destination;
169 /// without CTX, behaves like -Z
170 opt Context("context") => String [
171 excludes SelinuxDefault
172 ]
173
174 /// explain what is being done
175 opt Verbose("v", "verbose") => Bool
176
177 /// explain how each file is copied (implies -v)
178 opt Debug("debug") => Bool
179
180
181 /// display help and exit
182 opt Help("help") => Bool [
183 excludes All
184 ]
185
186 /// output version information and exit
187 opt Version("version") => Bool [
188 excludes All
189 ]
190}