Skip to content

Commit 6b768d4

Browse files
authored
Merge pull request #946 from techytushar/example-text
Add example text to external file
2 parents 7884468 + 2ea651a commit 6b768d4

File tree

2 files changed

+88
-91
lines changed

2 files changed

+88
-91
lines changed

src/scancode/cli.py

Lines changed: 2 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@
8282
from scancode.utils import BaseCommand
8383
from scancode.utils import path_progress_message
8484
from scancode.utils import progressmanager
85+
from scancode.help import examples_text
86+
from scancode.help import epilog_text
8587

8688
# Python 2 and 3 support
8789
try:
@@ -116,76 +118,6 @@ def logger_debug(*args):
116118

117119
echo_stderr = partial(click.secho, err=True)
118120

119-
# FIXME: this should be pushed out in some external help or pushed down in plugins.
120-
# FIXME: the glob story is very weird!!!
121-
examples_text = '''
122-
Scancode command lines examples:
123-
124-
(Note for Windows: use '\\' back slash instead of '/' forward slash for paths.)
125-
126-
Scan a single file for copyrights. Print scan results to stdout as JSON:
127-
128-
scancode --copyright samples/zlib/zlib.h --json
129-
130-
Scan a single file for licenses, print verbose progress to stderr as each
131-
file is scanned. Save scan to a JSON file:
132-
133-
scancode --license --verbose samples/zlib/zlib.h --json licenses.json
134-
135-
Scan a directory explicitly for licenses and copyrights. Redirect JSON scan
136-
results to a file:
137-
138-
scancode --json -l -c samples/zlib/ > scan.json
139-
140-
Scan a directory while ignoring a single file.
141-
Print scan results to stdout as JSON:
142-
143-
scancode --json --ignore README samples/
144-
145-
Scan a directory while ignoring all files with .txt extension.
146-
Print scan results to stdout as JSON.
147-
It is recommended to use quotes around glob patterns to prevent pattern
148-
expansion by the shell:
149-
150-
scancode --json --ignore "*.txt" samples/
151-
152-
Special characters supported in GLOB pattern:
153-
- * matches everything
154-
- ? matches any single character
155-
- [seq] matches any character in seq
156-
- [!seq] matches any character not in seq
157-
158-
For a literal match, wrap the meta-characters in brackets.
159-
For example, '[?]' matches the character '?'.
160-
For details on GLOB patterns see https://en.wikipedia.org/wiki/Glob_(programming).
161-
162-
Note: Glob patterns cannot be applied to path as strings.
163-
For example, this will not ignore "samples/JGroups/licenses".
164-
165-
scancode --json --ignore "samples*licenses" samples/
166-
167-
168-
Scan a directory while ignoring multiple files (or glob patterns).
169-
Print the scan results to stdout as JSON:
170-
171-
scancode --json --ignore README --ignore "*.txt" samples/
172-
173-
Scan the 'samples' directory for licenses and copyrights. Save scan results to
174-
an HTML app file for interactive scan results navigation. When the scan is done,
175-
open 'scancode_result.html' in your web browser. Note that additional app files
176-
are saved in a directory named 'scancode_result_files':
177-
178-
scancode --output-html-app scancode_result.html samples/
179-
180-
Scan a directory for licenses and copyrights. Save scan results to an
181-
HTML file:
182-
183-
scancode --output-html scancode_result.html samples/zlib
184-
185-
To extract archives, see the 'extractcode' command instead.
186-
'''
187-
188-
189121
def print_examples(ctx, param, value):
190122
if not value or ctx.resilient_parsing:
191123
return
@@ -200,27 +132,6 @@ def print_version(ctx, param, value):
200132
ctx.exit()
201133

202134

203-
# FIXME: this should be pushed out in some external help or pushed down in plugins.
204-
epilog_text = '''Examples (use --examples for more):
205-
206-
\b
207-
Scan the 'samples' directory for licenses and copyrights.
208-
Save scan results to the 'scancode_result.json' JSON file:
209-
210-
scancode --license --copyright --json=scancode_result.json samples
211-
212-
\b
213-
Scan the 'samples' directory for licenses and package manifests. Print scan
214-
results on screen as pretty-formatted JSON (using the special '-' FILE to print
215-
to on screen/to stdout):
216-
217-
scancode --json-pp - --license --package samples
218-
219-
Note: when you run scancode, a progress bar is displayed with a counter of the
220-
number of files processed. Use --verbose to display file-by-file progress.
221-
'''
222-
223-
224135
class ScanCommand(BaseCommand):
225136
"""
226137
A command class that is aware of ScanCode options that provides enhanced

src/scancode/help.py

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# FIXME: the glob story is very weird!!!
2+
examples_text = '''
3+
Scancode command lines examples:
4+
5+
(Note for Windows: use '\\' back slash instead of '/' forward slash for paths.)
6+
7+
Scan a single file for copyrights. Print scan results to stdout as JSON:
8+
9+
scancode --copyright samples/zlib/zlib.h --json
10+
11+
Scan a single file for licenses, print verbose progress to stderr as each
12+
file is scanned. Save scan to a JSON file:
13+
14+
scancode --license --verbose samples/zlib/zlib.h --json licenses.json
15+
16+
Scan a directory explicitly for licenses and copyrights. Redirect JSON scan
17+
results to a file:
18+
19+
scancode --json -l -c samples/zlib/ > scan.json
20+
21+
Scan a directory while ignoring a single file.
22+
Print scan results to stdout as JSON:
23+
24+
scancode --json --ignore README samples/
25+
26+
Scan a directory while ignoring all files with .txt extension.
27+
Print scan results to stdout as JSON.
28+
It is recommended to use quotes around glob patterns to prevent pattern
29+
expansion by the shell:
30+
31+
scancode --json --ignore "*.txt" samples/
32+
33+
Special characters supported in GLOB pattern:
34+
- * matches everything
35+
- ? matches any single character
36+
- [seq] matches any character in seq
37+
- [!seq] matches any character not in seq
38+
39+
For a literal match, wrap the meta-characters in brackets.
40+
For example, '[?]' matches the character '?'.
41+
For details on GLOB patterns see https://en.wikipedia.org/wiki/Glob_(programming).
42+
43+
Note: Glob patterns cannot be applied to path as strings.
44+
For example, this will not ignore "samples/JGroups/licenses".
45+
46+
scancode --json --ignore "samples*licenses" samples/
47+
48+
49+
Scan a directory while ignoring multiple files (or glob patterns).
50+
Print the scan results to stdout as JSON:
51+
52+
scancode --json --ignore README --ignore "*.txt" samples/
53+
54+
Scan the 'samples' directory for licenses and copyrights. Save scan results to
55+
an HTML app file for interactive scan results navigation. When the scan is done,
56+
open 'scancode_result.html' in your web browser. Note that additional app files
57+
are saved in a directory named 'scancode_result_files':
58+
59+
scancode --output-html-app scancode_result.html samples/
60+
61+
Scan a directory for licenses and copyrights. Save scan results to an
62+
HTML file:
63+
64+
scancode --output-html scancode_result.html samples/zlib
65+
66+
To extract archives, see the 'extractcode' command instead.
67+
'''
68+
69+
epilog_text = '''Examples (use --examples for more):
70+
71+
\b
72+
Scan the 'samples' directory for licenses and copyrights.
73+
Save scan results to the 'scancode_result.json' JSON file:
74+
75+
scancode --license --copyright --json=scancode_result.json samples
76+
77+
\b
78+
Scan the 'samples' directory for licenses and package manifests. Print scan
79+
results on screen as pretty-formatted JSON (using the special '-' FILE to print
80+
to on screen/to stdout):
81+
82+
scancode --json-pp - --license --package samples
83+
84+
Note: when you run scancode, a progress bar is displayed with a counter of the
85+
number of files processed. Use --verbose to display file-by-file progress.
86+
'''

0 commit comments

Comments
 (0)