Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
file-boilerplate
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Rylie Pavlik
file-boilerplate
Commits
53390e9d
Commit
53390e9d
authored
5 years ago
by
Rylie Pavlik
Browse files
Options
Downloads
Patches
Plain Diff
command_line: Allow arbitrary file types to be generated.
parent
012de094
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
file_boilerplate/command_line.py
+15
-8
15 additions, 8 deletions
file_boilerplate/command_line.py
with
15 additions
and
8 deletions
file_boilerplate/command_line.py
+
15
−
8
View file @
53390e9d
#!/usr/bin/python3
# -*- coding: utf-8 -*-
#
# Copyright (c) 2018 Collabora, Ltd.
# Copyright (c) 2018
-2019
Collabora, Ltd.
#
# SPDX-License-Identifier: BSL-1.0
#
# Author(s): Ryan Pavlik <ryan.pavlik@collabora.com>
#
# Purpose: Generates
a
.cpp and .h
file
with the given stem,
# Purpose: Generates
code files (by default
.cpp and .h
)
with the given stem,
# containing the expected default/boilerplate contents
import
argparse
from
file_boilerplate
import
BoilerplateRun
from
sys
import
exit
def
main
():
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'
stem
'
,
metavar
=
'
stem
'
,
nargs
=
'
?
'
,
help
=
'
Specify generated filename stem (.cpp and .h will be added)
'
)
help
=
'
Specify generated filename stem (
file extensions
.cpp and .h will be added)
'
)
parser
.
add_argument
(
'
--noh
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Skip generating the .h file
'
)
parser
.
add_argument
(
'
--nocpp
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Skip generating the .cpp file
'
)
parser
.
add_argument
(
'
-t
'
,
'
--type
'
,
action
=
'
append
'
,
default
=
[],
help
=
'
Specify file types (nominally, extensions) to explicitly use.
'
)
parser
.
add_argument
(
'
-f
'
,
'
--force
'
,
action
=
'
store_true
'
,
default
=
False
,
help
=
'
Write file(s) even if already existing
'
)
args
=
parser
.
parse_args
()
success
=
True
run
=
BoilerplateRun
()
if
not
args
.
noh
:
file_types
=
args
.
type
if
not
file_types
:
if
not
args
.
noh
:
file_types
.
append
(
'
h
'
)
if
not
args
.
nocpp
:
file_types
.
append
(
'
cpp
'
)
for
file_type
in
file_types
:
success
=
run
.
render
(
stem
=
args
.
stem
,
ext
=
"
h
"
).
write
(
force
=
args
.
force
)
and
success
ext
=
file_type
).
write
(
force
=
args
.
force
)
and
success
if
not
args
.
nocpp
:
success
=
run
.
render
(
ext
=
'
cpp
'
,
stem
=
args
.
stem
).
write
(
force
=
args
.
force
)
and
success
if
success
:
exit
()
exit
(
-
1
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment