Skip to content

Commit 4a4d928

Browse files
committed
chore: cleanup legacy tests
1 parent d0d80f5 commit 4a4d928

File tree

2 files changed

+73
-19
lines changed

2 files changed

+73
-19
lines changed

README.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
[![version][npm-badge]][npm-link] [![repo][github-src]][github-link]
44

5-
A CLI to download specific parts of Git repositories using sparse-checkout. Supports GitHub and GitLab urls.
5+
A CLI to download specific parts of Git repositories using sparse-checkout.
66

77
- 10x faster than `gitpick`
8-
- Works with GitHub and GitLab urls
8+
- Supports GitHub and GitLab urls.
99

1010
[github-src]: https://badgen.net/badge/-/amio%2Fgitok/black?icon=github&label=
1111
[github-link]: https://github.com/amio/gitok
@@ -27,26 +27,47 @@ npx gitok <url>
2727
### Basic Repository Clone
2828

2929
```bash
30-
# Clone entire repository (GitHub)
30+
# Clone entire repository (GitHub/GitLab)
3131
gitok https://github.com/owner/repo
32-
33-
# Clone entire repository (GitLab)
3432
gitok https://gitlab.com/owner/repo
3533

36-
# Clone specific folder from main branch (GitHub)
34+
# Clone specific folder from main branch (GitHub/GitLab)
3735
gitok https://github.com/owner/repo/tree/main/path/to/folder
38-
39-
# Clone specific folder from main branch (GitLab)
4036
gitok https://gitlab.com/owner/repo/-/tree/main/path/to/folder
4137

4238
# Clone specific folder from different branch
4339
gitok https://github.com/owner/repo/tree/develop/src/components
4440
gitok https://gitlab.com/owner/repo/-/tree/develop/src/components
4541
```
4642

47-
### Custom Output Directory
43+
### Full Help
4844

4945
```bash
50-
# Specify custom output directory name
51-
gitok https://github.com/owner/repo/tree/main/examples custom-directory
46+
Usage: gitok [options] <url> [output]
47+
48+
A CLI tool to quickly clone specific parts of git repositories
49+
50+
Arguments:
51+
url Git repository URL (GitHub or GitLab)
52+
output Output directory name (optional)
53+
54+
Options:
55+
-V, --version output the version number
56+
-b, --branch <branch> Branch to clone from
57+
-v, --verbose Show detailed output logs
58+
-h, --help display help for command
59+
60+
Examples:
61+
# Clone the entire repository
62+
$ gitok https://github.com/user/repo
63+
64+
# Clone only a subdirectory from GitHub
65+
$ gitok https://github.com/user/repo/tree/main/path/to/subdir
66+
67+
# Clone only a subdirectory from GitLab
68+
$ gitok https://gitlab.com/group/project/-/tree/master/path/to/subdir
5269
```
70+
71+
## License
72+
73+
MIT License © 2025 Amio

test/cli.test.js

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,54 @@ test('CLI Tests', async (t) => {
3333
assert.ok(result.stdout.includes('Usage:'));
3434
});
3535

36-
await t.test('should display version when run with --version', async () => {
37-
const result = await runCLI(['--version']);
36+
await t.test('should display help when run without arguments', async () => {
37+
const result = await runCLI([]);
3838
assert.strictEqual(result.code, 0);
39-
assert.ok(result.stdout.includes('1.0.0'));
39+
assert.ok(result.stdout.includes('gitok'));
40+
assert.ok(result.stdout.includes('Usage:'));
4041
});
4142

42-
await t.test('should show error for missing URL argument', async () => {
43-
const result = await runCLI([]);
43+
await t.test('should show error for invalid Git URL', async () => {
44+
const result = await runCLI(['https://bitbucket.org/owner/repo']);
4445
assert.notStrictEqual(result.code, 0);
45-
assert.ok(result.stderr.includes('error') || result.stdout.includes('required'));
46+
assert.ok(result.stderr.includes('Invalid Git URL format'));
4647
});
4748

48-
await t.test('should show error for invalid Git URL', async () => {
49-
const result = await runCLI(['https://bitbucket.org/owner/repo']);
49+
await t.test('should show error for URL with query parameters', async () => {
50+
const result = await runCLI(['https://github.com/owner/repo?tab=readme']);
5051
assert.notStrictEqual(result.code, 0);
5152
assert.ok(result.stderr.includes('Invalid Git URL format'));
5253
});
54+
55+
await t.test('should show error for URL with fragments', async () => {
56+
const result = await runCLI(['https://github.com/owner/repo#readme']);
57+
assert.notStrictEqual(result.code, 0);
58+
assert.ok(result.stderr.includes('Invalid Git URL format'));
59+
});
60+
61+
await t.test('should show error for empty URL', async () => {
62+
const result = await runCLI(['']);
63+
assert.notStrictEqual(result.code, 0);
64+
assert.ok(result.stderr.includes('Invalid Git URL format'));
65+
});
66+
67+
await t.test('should validate GitHub URL format', async () => {
68+
const result = await runCLI(['https://github.com/invalid-url-format']);
69+
assert.notStrictEqual(result.code, 0);
70+
assert.ok(result.stderr.includes('Invalid Git URL format'));
71+
});
72+
73+
await t.test('should validate GitLab URL format', async () => {
74+
const result = await runCLI(['https://gitlab.com/invalid-url-format']);
75+
assert.notStrictEqual(result.code, 0);
76+
assert.ok(result.stderr.includes('Invalid Git URL format'));
77+
});
78+
79+
await t.test('should show usage examples in help text', async () => {
80+
const result = await runCLI(['--help']);
81+
assert.strictEqual(result.code, 0);
82+
assert.ok(result.stdout.includes('Examples:'));
83+
assert.ok(result.stdout.includes('github.com'));
84+
assert.ok(result.stdout.includes('gitlab.com'));
85+
});
5386
});

0 commit comments

Comments
 (0)