include::include/header.adoc[]

== Name

bite-bugzilla-attachment-create - create attachments

== Synopsis

*bite bugzilla attachment <create|c>* [<options>] [id[,...]] <files>::
    Create attachments.

*bite bugzilla attachment <create|c>* [-h|--help]::
    Output help information.

== Description

Create attachments.

include::include/global-options.adoc[]

== Attachment options

*-c, --comment* <value>::
    Comment to add with the attachment.

*-d, --description* <value>::
    A short description of the attachment.
+
By default the submitted file name is used.

*-f, --flags* <value>[,...]::
    Attachment flags.

*-m, --mime* <type>::
    Specify the MIME type of the attachment.
+
This option is unnecessary for regular usage since bugbite automatically
determines the MIME type using `file` with a fallback to data inference for
common file types; however, `file` often misidentifies plain text file types so
text/plain may need to be forced.
+
In addition, setting the MIME type isn't allowed for directory targets as it is
automatically determined.
+
.Attach build.log with forced MIME type:
 bite bugzilla attachment create 10 build.log --mime text/plain

*-n, --name* <value>::
    File name of the attachment.
+
By default the submitted file name is used.

*-p, --patch* [<bool>]::
    Mark attachment as a patch.

*-P, --private* [<bool>]::
    Mark attachment private.

== Compression options

*-C, --compress* [<variant>]::
    Compress attachments.
+
The value must be the compression variant to use or can be skipped to use the
default: xz. Using compression requires the related utility installed.
+
.Compress attachment using the default type:
 bite bugzilla attachment create 10 file --compress
+
.Compress attachment using zstd:
 bite bugzilla attachment create 10 file --compress zstd
+
.Available compression variants and the tools they require:
- bz2: bzip2
- gz: gzip
- lz: lzip
- xz: xz
- zstd: zstd

*--auto-compress* [<size>]::
    Auto-compress attachments larger than a given size.
+
The value is the file size limit above which attachments will be compressed,
defaulting to 1000KiB when not given. Standard unit symbols should be used with
the size, otherwise bytes are assumed.
+
.Auto-compress using the defaults:
 bite bugzilla attachment create 10 file --auto-compress
+
.Auto-compress using zstd with 5MB size limit:
 bite bugzilla attachment create 10 file --auto-compress 5MB --compress zstd

*--auto-truncate* [<lines>]::
    Auto-truncate text attachments to a given number of lines.
+
The value must be the number of lines to which the file will be truncated
starting from the end, defaulting to 1000 lines when not given.
+
This option works in coordination with --auto-compress using the file size
limit to trigger when a text file is truncated. If the option is not specified
the default value will be used for it.
+
.Auto-truncate to 1000 lines:
 bite bugzilla attachment create 10 file.txt --auto-truncate
+
.Auto-truncate to 5000 lines and compress using zstd:
 bite bugzilla attachment create 10 file.txt --auto-truncate 5000 --compress zstd

== Arguments

<id[,...]>::
    IDs or aliases of bugs to create attachments for.
+
Taken from standard input when `-`.
+
.Attach to all matching bugs:
 bite bugzilla search bugbite -f id | bite bugzilla attachment create - path/to/file

.Attach to multiple bugs:
 bite bugzilla attachment create 3,4,5 file

<files>::
    Paths to attachment files.
+
Multiple attachments can be created by specifying multiple files.
+
.Attach multiple files:
 bite bugzilla attachment create 3 file1 file2 path/to/file3

== Examples

.Attach compressed tarball of directory:
 bite bugzilla attachment create 10 path/to/dir

.Attach tarball compressed with zstd:
 bite bugzilla attachment create 10 path/to/dir --compress zstd

== See Also

linkcmd:bite-bugzilla-attachment[1]
