Skip to content

Commit f44dde1

Browse files
authored
Merge pull request #1139 from ia0/stable
Commit the CLI to stability
2 parents b0e9ba0 + bae2491 commit f44dde1

File tree

14 files changed

+69
-184
lines changed

14 files changed

+69
-184
lines changed

README.md

Lines changed: 1 addition & 133 deletions
Original file line numberDiff line numberDiff line change
@@ -88,139 +88,7 @@ docker run -it --rm -v $(pwd):/magika magika -r /magika/tests_data/basic
8888

8989
### Command line client
9090

91-
Magika is available as a command line tool, written in Rust (the `magika` python package ships this client). Here below are a few examples on how to use it, and the output of `magika --help`, which documents the list of options. See [here](./rust/cli/README.md) for developer notes and documentation on how to install the Rust client via `cargo`.
92-
93-
Examples:
94-
95-
```shell
96-
$ cd tests_data/basic && magika -r *
97-
asm/code.asm: Assembly (code)
98-
batch/simple.bat: DOS batch file (code)
99-
c/code.c: C source (code)
100-
css/code.css: CSS source (code)
101-
csv/magika_test.csv: CSV document (code)
102-
dockerfile/Dockerfile: Dockerfile (code)
103-
docx/doc.docx: Microsoft Word 2007+ document (document)
104-
epub/doc.epub: EPUB document (document)
105-
epub/magika_test.epub: EPUB document (document)
106-
flac/test.flac: FLAC audio bitstream data (audio)
107-
handlebars/example.handlebars: Handlebars source (code)
108-
html/doc.html: HTML document (code)
109-
ini/doc.ini: INI configuration file (text)
110-
javascript/code.js: JavaScript source (code)
111-
jinja/example.j2: Jinja template (code)
112-
jpeg/magika_test.jpg: JPEG image data (image)
113-
json/doc.json: JSON document (code)
114-
latex/sample.tex: LaTeX document (text)
115-
makefile/simple.Makefile: Makefile source (code)
116-
markdown/README.md: Markdown document (text)
117-
[...]
118-
```
119-
120-
```shell
121-
$ magika ./tests_data/basic/python/code.py --json
122-
[
123-
{
124-
"path": "./tests_data/basic/python/code.py",
125-
"result": {
126-
"status": "ok",
127-
"value": {
128-
"dl": {
129-
"description": "Python source",
130-
"extensions": [
131-
"py",
132-
"pyi"
133-
],
134-
"group": "code",
135-
"is_text": true,
136-
"label": "python",
137-
"mime_type": "text/x-python"
138-
},
139-
"output": {
140-
"description": "Python source",
141-
"extensions": [
142-
"py",
143-
"pyi"
144-
],
145-
"group": "code",
146-
"is_text": true,
147-
"label": "python",
148-
"mime_type": "text/x-python"
149-
},
150-
"score": 0.753000020980835
151-
}
152-
}
153-
}
154-
]
155-
```
156-
157-
```shell
158-
$ cat doc.ini | magika -
159-
-: INI configuration file (text)
160-
```
161-
162-
```help
163-
$ magika --help
164-
Determines the content type of files with deep-learning
165-
166-
Usage: magika [OPTIONS] [PATH]...
167-
168-
Arguments:
169-
[PATH]...
170-
List of paths to the files to analyze.
171-
172-
Use a dash (-) to read from standard input (can only be used once).
173-
174-
Options:
175-
-r, --recursive
176-
Identifies files within directories instead of identifying the directory itself
177-
178-
--no-dereference
179-
Identifies symbolic links as is instead of identifying their content by following them
180-
181-
--colors
182-
Prints with colors regardless of terminal support
183-
184-
--no-colors
185-
Prints without colors regardless of terminal support
186-
187-
-s, --output-score
188-
Prints the prediction score in addition to the content type
189-
190-
-i, --mime-type
191-
Prints the MIME type instead of the content type description
192-
193-
-l, --label
194-
Prints a simple label instead of the content type description
195-
196-
--json
197-
Prints in JSON format
198-
199-
--jsonl
200-
Prints in JSONL format
201-
202-
--format <CUSTOM>
203-
Prints using a custom format (use --help for details).
204-
205-
The following placeholders are supported:
206-
207-
%p The file path
208-
%l The unique label identifying the content type
209-
%d The description of the content type
210-
%g The group of the content type
211-
%m The MIME type of the content type
212-
%e Possible file extensions for the content type
213-
%s The score of the content type for the file
214-
%S The score of the content type for the file in percent
215-
%b The model output if overruled (empty otherwise)
216-
%% A literal %
217-
218-
-h, --help
219-
Print help (see a summary with '-h')
220-
221-
-V, --version
222-
Print version
223-
```
91+
Magika is available as a command line tool, written in Rust (the `magika` python package ships this client). The output of `magika --help` and the [README](./rust/cli/README.md) document the list of options.
22492

22593
### Python module and other bindings
22694

rust/cli/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
## 1.0.0-dev
4+
5+
### Patch
6+
7+
- Change description
8+
- Update dependencies
9+
310
## 0.1.4
411

512
### Minor

rust/cli/Cargo.lock

Lines changed: 11 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/cli/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "magika"
3-
version = "0.1.4"
3+
version = "1.0.0-dev"
44
authors = ["Magika Developers <magika-dev@google.com>"]
55
license = "Apache-2.0"
66
edition = "2021"
7-
description = "Determines the content type of a file with deep-learning"
7+
description = "Determines file content types using AI"
88
repository = "https://github.com/google/magika"
99
homepage = "https://google.github.io/magika/"
1010
keywords = ["cli", "file", "magic"]
@@ -16,7 +16,7 @@ anyhow = "1.0.86"
1616
async-channel = "2.3.1"
1717
clap = { version = "4.5.9", features = ["cargo", "derive", "string"] }
1818
colored = "3.0.0"
19-
magika_lib = { package = "magika", version = "=0.2.1", path = "../lib", features = ["serde"] }
19+
magika_lib = { package = "magika", version = "=0.2.2-dev", path = "../lib", features = ["serde"] }
2020
num_cpus = "1.16.0"
2121
ort = "=2.0.0-rc.10"
2222
serde = { version = "1.0.204", features = ["derive"] }

rust/cli/README.md

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Magika CLI
22

33
This binary crate implements a command-line interface (CLI) to the library crate
4-
[magika](https://crates.io/crates/magika) which provides file type detection with deep-learning.
4+
[magika](https://crates.io/crates/magika) which provides file content type detection using AI.
55

66
## Disclaimer
77

@@ -46,32 +46,21 @@ cargo install --locked --path=rust/cli
4646
## Examples
4747

4848
```shell
49-
$ cd tests_data/basic && magika -r *
49+
% cd tests_data/basic && magika -r * | head
5050
asm/code.asm: Assembly (code)
5151
batch/simple.bat: DOS batch file (code)
5252
c/code.c: C source (code)
5353
css/code.css: CSS source (code)
5454
csv/magika_test.csv: CSV document (code)
5555
dockerfile/Dockerfile: Dockerfile (code)
5656
docx/doc.docx: Microsoft Word 2007+ document (document)
57-
epub/doc.epub: EPUB document (document)
58-
epub/magika_test.epub: EPUB document (document)
59-
flac/test.flac: FLAC audio bitstream data (audio)
60-
handlebars/example.handlebars: Handlebars source (code)
61-
html/doc.html: HTML document (code)
62-
ini/doc.ini: INI configuration file (text)
63-
javascript/code.js: JavaScript source (code)
64-
jinja/example.j2: Jinja template (code)
65-
jpeg/magika_test.jpg: JPEG image data (image)
66-
json/doc.json: JSON document (code)
67-
latex/sample.tex: LaTeX document (text)
68-
makefile/simple.Makefile: Makefile source (code)
69-
markdown/README.md: Markdown document (text)
70-
[...]
57+
docx/magika_test.docx: Microsoft Word 2007+ document (document)
58+
eml/sample.eml: RFC 822 mail (text)
59+
empty/empty_file: Empty file (inode)
7160
```
7261

7362
```shell
74-
$ magika ./tests_data/basic/python/code.py --json
63+
% magika ./tests_data/basic/python/code.py --json
7564
[
7665
{
7766
"path": "./tests_data/basic/python/code.py",
@@ -100,21 +89,21 @@ $ magika ./tests_data/basic/python/code.py --json
10089
"label": "python",
10190
"mime_type": "text/x-python"
10291
},
103-
"score": 0.753000020980835
92+
"score": 0.996999979019165
10493
}
10594
}
10695
}
10796
]
10897
```
10998

11099
```shell
111-
$ cat doc.ini | magika -
100+
% cat tests_data/basic/ini/doc.ini | magika -
112101
-: INI configuration file (text)
113102
```
114103

115-
```help
116-
$ magika --help
117-
Determines the content type of files with deep-learning
104+
```shell
105+
% magika --help
106+
Determines file content types using AI
118107

119108
Usage: magika [OPTIONS] [PATH]...
120109

rust/cli/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use serde::Serialize;
3131
use tokio::fs::File;
3232
use tokio::io::AsyncReadExt;
3333

34-
/// Determines the content type of files with deep-learning.
34+
/// Determines file content types using AI.
3535
#[derive(Parser)]
3636
#[command(name = "magika", version = Version, arg_required_else_help = true)]
3737
struct Flags {

rust/lib/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.2.2-dev
4+
5+
### Patch
6+
7+
- Change description and documentation
8+
39
## 0.2.1
410

511
### Patch

rust/lib/Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/lib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "magika"
3-
version = "0.2.1"
3+
version = "0.2.2-dev"
44
authors = ["Magika Developers <magika-dev@google.com>"]
55
license = "Apache-2.0"
66
edition = "2021"
7-
description = "Determines the content type of a file with deep-learning"
7+
description = "Determines file content types using AI"
88
repository = "https://github.com/google/magika"
99
homepage = "https://google.github.io/magika/"
1010
keywords = ["file", "magic"]

rust/lib/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Magika
22

3-
This library crate provides file type detection with deep-learning. A command-line interface (CLI)
4-
for this library is provided by the [magika-cli](https://crates.io/crates/magika-cli) binary crate.
3+
This library crate provides file content type detection using AI. A command-line interface (CLI) for
4+
this library is provided by the [magika-cli](https://crates.io/crates/magika-cli) binary crate.
55

66
## Disclaimer
77

0 commit comments

Comments
 (0)