1+ <!--
2+ -- Copyright (C) 2020 Arm Mbed. All rights reserved.
3+ -- SPDX-License-Identifier: Apache-2.0
4+ -->
5+ <!doctype html>
6+ < html lang ="en ">
7+ < head >
8+ < meta charset ="utf-8 ">
9+ < meta name ="viewport " content ="width=device-width, initial-scale=1, minimum-scale=1 " />
10+ < meta name ="generator " content ="pdoc 0.7.5 " />
11+ < title > snippet.cli API documentation</ title >
12+ < meta name ="description " content ="CLI definition. " />
13+ < link href ='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css ' rel ='stylesheet '>
14+ < link href ='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css ' rel ='stylesheet '>
15+ < link href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css " rel ="stylesheet ">
16+ < style > .flex {display : flex !important }body {line-height : 1.5em }# content {padding : 20px }# sidebar {padding : 30px ;overflow : hidden}.http-server-breadcrumbs {font-size : 130% ;margin : 0 0 15px 0 }# footer {font-size : .75em ;padding : 5px 30px ;border-top : 1px solid # ddd ;text-align : right}# footer p {margin : 0 0 0 1em ;display : inline-block}# footer p : last-child {margin-right : 30px }h1 , h2 , h3 , h4 , h5 {font-weight : 300 }h1 {font-size : 2.5em ;line-height : 1.1em }h2 {font-size : 1.75em ;margin : 1em 0 .50em 0 }h3 {font-size : 1.4em ;margin : 25px 0 10px 0 }h4 {margin : 0 ;font-size : 105% }a {color : # 058 ;text-decoration : none;transition : color .3s ease-in-out}a : hover {color : # e82 }.title code {font-weight : bold}h2 [id ^= "header-" ]{margin-top : 2em }.ident {color : # 900 }pre code {background : # f8f8f8 ;font-size : .8em ;line-height : 1.4em }code {background : # f2f2f1 ;padding : 1px 4px ;overflow-wrap : break-word}h1 code {background : transparent}pre {background : # f8f8f8 ;border : 0 ;border-top : 1px solid # ccc ;border-bottom : 1px solid # ccc ;margin : 1em 0 ;padding : 1ex }# http-server-module-list {display : flex;flex-flow : column}# http-server-module-list div {display : flex}# http-server-module-list dt {min-width : 10% }# http-server-module-list p {margin-top : 0 }.toc ul , # index {list-style-type : none;margin : 0 ;padding : 0 }# index code {background : transparent}# index h3 {border-bottom : 1px solid # ddd }# index ul {padding : 0 }# index h4 {font-weight : bold}# index h4 + ul {margin-bottom : .6em }@media (min-width : 200ex ){# index .two-column {column-count : 2 }}@media (min-width : 300ex ){# index .two-column {column-count : 3 }}dl {margin-bottom : 2em }dl dl : last-child {margin-bottom : 4em }dd {margin : 0 0 1em 3em }# header-classes + dl > dd {margin-bottom : 3em }dd dd {margin-left : 2em }dd p {margin : 10px 0 }.name {background : # eee ;font-weight : bold;font-size : .85em ;padding : 5px 10px ;display : inline-block;min-width : 40% }.name : hover {background : # e0e0e0 }.name > span : first-child {white-space : nowrap}.name .class > span : nth-child (2 ){margin-left : .4em }.inherited {color : # 999 ;border-left : 5px solid # eee ;padding-left : 1em }.inheritance em {font-style : normal;font-weight : bold}.desc h2 {font-weight : 400 ;font-size : 1.25em }.desc h3 {font-size : 1em }.desc dt code {background : inherit}.source summary , .git-link-div {color : # 666 ;text-align : right;font-weight : 400 ;font-size : .8em ;text-transform : uppercase}.source summary > * {white-space : nowrap;cursor : pointer}.git-link {color : inherit;margin-left : 1em }.source pre {max-height : 500px ;overflow : auto;margin : 0 }.source pre code {font-size : 12px ;overflow : visible}.hlist {list-style : none}.hlist li {display : inline}.hlist li : after {content : ',\2002' }.hlist li : last-child : after {content : none}.hlist .hlist {display : inline;padding-left : 1em }img {max-width : 100% }.admonition {padding : .1em .5em ;margin-bottom : 1em }.admonition-title {font-weight : bold}.admonition .note , .admonition .info , .admonition .important {background : # aef }.admonition .todo , .admonition .versionadded , .admonition .tip , .admonition .hint {background : # dfd }.admonition .warning , .admonition .versionchanged , .admonition .deprecated {background : # fd4 }.admonition .error , .admonition .danger , .admonition .caution {background : lightpink}</ style >
17+ < style media ="screen and (min-width: 700px) "> @media screen and (min-width : 700px ){# sidebar {width : 30% }# content {width : 70% ;max-width : 100ch ;padding : 3em 4em ;border-left : 1px solid # ddd }pre code {font-size : 1em }.item .name {font-size : 1em }main {display : flex;flex-direction : row-reverse;justify-content : flex-end}.toc ul ul , # index ul {padding-left : 1.5em }.toc > ul > li {margin-top : .5em }}</ style >
18+ < style media ="print "> @media print{# sidebar h1 {page-break-before : always}.source {display : none}}@media print{* {background : transparent !important ;color : # 000 !important ;box-shadow : none !important ;text-shadow : none !important }a [href ]: after {content : " (" attr (href) ")" ;font-size : 90% }a [href ][title ]: after {content : none}abbr [title ]: after {content : " (" attr (title) ")" }.ir a : after , a [href ^= "javascript:" ]: after , a [href ^= "#" ]: after {content : "" }pre , blockquote {border : 1px solid # 999 ;page-break-inside : avoid}thead {display : table-header-group}tr , img {page-break-inside : avoid}img {max-width : 100% !important }@page {margin : 0.5cm }p , h2 , h3 {orphans : 3 ;widows : 3 }h1 , h2 , h3 , h4 , h5 , h6 {page-break-after : avoid}}</ style >
19+ </ head >
20+ < body >
21+ < main >
22+ < article id ="content ">
23+ < header >
24+ < h1 class ="title "> Module < code > snippet.cli</ code > </ h1 >
25+ </ header >
26+ < section id ="section-intro ">
27+ < p > CLI definition.</ p >
28+ < details class ="source ">
29+ < summary >
30+ < span > Expand source code</ span >
31+ </ summary >
32+ < pre > < code class ="python "> #
33+ # Copyright (C) 2020 Arm Mbed. All rights reserved.
34+ # SPDX-License-Identifier: Apache-2.0
35+ #
36+ """CLI definition."""
37+ import argparse
38+
39+ import os
40+ import sys
41+ import dotenv
42+
43+ from mbed_tools_lib.logging import set_log_level, MbedToolsHandler
44+
45+ from snippet import config
46+ from snippet.api import extract_code_snippets
47+ from snippet._internal.logs import LOGGER
48+
49+
50+ def main() -> int:
51+ """Script CLI."""
52+ parser = argparse.ArgumentParser()
53+ parser.add_argument("--config", type=str, action="append", help="paths (or globs) to config files")
54+ parser.add_argument(
55+ "dir",
56+ nargs="?",
57+ default=os.getcwd(),
58+ help="path to project root, used by any relative paths in loaded configs [cwd]",
59+ )
60+ parser.add_argument(
61+ "-v",
62+ "--verbose",
63+ action="count",
64+ default=0,
65+ help="Set the verbosity level, enter multiple times to increase verbosity.",
66+ )
67+ parser.add_argument(
68+ "-t", "--traceback", action="store_true", default=True, help="Show a traceback when an error is raised."
69+ )
70+ args = parser.parse_args()
71+ set_log_level(args.verbose)
72+ dotenv.load_dotenv(dotenv.find_dotenv(usecwd=True, raise_error_if_not_found=False))
73+ # Use the context manager to ensure tools exceptions (expected behaviour) are shown as messages to the user,
74+ # but all other exceptions (unexpected behaviour) are shown as errors.
75+ with MbedToolsHandler(LOGGER, args.traceback):
76+ extract_code_snippets(config.get_config(config_paths=args.config, project_root=args.dir,))
77+ return 0
78+ return 1
79+
80+
81+ if __name__ == "__main__":
82+ sys.exit(main())</ code > </ pre >
83+ </ details >
84+ </ section >
85+ < section >
86+ </ section >
87+ < section >
88+ </ section >
89+ < section >
90+ < h2 class ="section-title " id ="header-functions "> Functions</ h2 >
91+ < dl >
92+ < dt id ="snippet.cli.main "> < code class ="name flex ">
93+ < span > def < span class ="ident "> main</ span > </ span > (< span > ) -> int</ span >
94+ </ code > </ dt >
95+ < dd >
96+ < section class ="desc "> < p > Script CLI.</ p > </ section >
97+ < details class ="source ">
98+ < summary >
99+ < span > Expand source code</ span >
100+ </ summary >
101+ < pre > < code class ="python "> def main() -> int:
102+ """Script CLI."""
103+ parser = argparse.ArgumentParser()
104+ parser.add_argument("--config", type=str, action="append", help="paths (or globs) to config files")
105+ parser.add_argument(
106+ "dir",
107+ nargs="?",
108+ default=os.getcwd(),
109+ help="path to project root, used by any relative paths in loaded configs [cwd]",
110+ )
111+ parser.add_argument(
112+ "-v",
113+ "--verbose",
114+ action="count",
115+ default=0,
116+ help="Set the verbosity level, enter multiple times to increase verbosity.",
117+ )
118+ parser.add_argument(
119+ "-t", "--traceback", action="store_true", default=True, help="Show a traceback when an error is raised."
120+ )
121+ args = parser.parse_args()
122+ set_log_level(args.verbose)
123+ dotenv.load_dotenv(dotenv.find_dotenv(usecwd=True, raise_error_if_not_found=False))
124+ # Use the context manager to ensure tools exceptions (expected behaviour) are shown as messages to the user,
125+ # but all other exceptions (unexpected behaviour) are shown as errors.
126+ with MbedToolsHandler(LOGGER, args.traceback):
127+ extract_code_snippets(config.get_config(config_paths=args.config, project_root=args.dir,))
128+ return 0
129+ return 1</ code > </ pre >
130+ </ details >
131+ </ dd >
132+ </ dl >
133+ </ section >
134+ < section >
135+ </ section >
136+ </ article >
137+ < nav id ="sidebar ">
138+ < h1 > Index</ h1 >
139+ < div class ="toc ">
140+ < ul > </ ul >
141+ </ div >
142+ < ul id ="index ">
143+ < li > < h3 > Super-module</ h3 >
144+ < ul >
145+ < li > < code > < a title ="snippet " href ="index.html "> snippet</ a > </ code > </ li >
146+ </ ul >
147+ </ li >
148+ < li > < h3 > < a href ="#header-functions "> Functions</ a > </ h3 >
149+ < ul class ="">
150+ < li > < code > < a title ="snippet.cli.main " href ="#snippet.cli.main "> main</ a > </ code > </ li >
151+ </ ul >
152+ </ li >
153+ </ ul >
154+ </ nav >
155+ </ main >
156+ < footer id ="footer ">
157+ < p > Generated by < a href ="https://pdoc3.github.io/pdoc "> < cite > pdoc</ cite > 0.7.5</ a > .</ p >
158+ </ footer >
159+ < script src ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js "> </ script >
160+ < script > hljs . initHighlightingOnLoad ( ) </ script >
161+ </ body >
162+ </ html >
0 commit comments