Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cc-cli
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Mirror
cc-cli
Commits
e4c2e492
Commit
e4c2e492
authored
14 years ago
by
Seblu
Browse files
Options
Downloads
Patches
Plain Diff
new initialization process
new profile loading schema
parent
3ae32cbe
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
README
+9
-1
9 additions, 1 deletion
README
bin/cc-cli
+48
-39
48 additions, 39 deletions
bin/cc-cli
with
57 additions
and
40 deletions
README
+
9
−
1
View file @
e4c2e492
...
...
@@ -12,11 +12,19 @@ You will find examples in examples subdirectory in git repository.
To quickly connect to mulptiple servers, you can define a profile by server.
=======
Loading
=======
Profile is loaded in this order:
1 load [cli] profile in ~/.config/cc-cli/profile
2 load profile specified by option profile in [cli] profile
3 load profile specified by environment
4 load profile specified on argument line
4 load profile specified on command line
5 load options from environment
6 load options from command line
Please note: Environment variable CC_DEBUG is loaded before every work to be
able to activate an early debugging.
===========
Environment
...
...
This diff is collapsed.
Click to expand it.
bin/cc-cli
+
48
−
39
View file @
e4c2e492
...
...
@@ -29,41 +29,13 @@ settings = {
}
try
:
# load a printer
printer
=
Printer
(
False
)
# parse profile file and load default profile
try
:
propath
=
"
%s/profile
"
%
BaseDirectory
.
save_config_path
(
cccli
.
canonical_name
)
fparser
=
ConfigParser
.
RawConfigParser
()
fparser
.
read
(
propath
)
if
fparser
.
has_section
(
"
cli
"
):
settings
.
update
(
fparser
.
items
(
"
cli
"
))
except
Exception
:
fparser
=
None
# load "default profile" profile
if
"
profile
"
in
settings
:
if
fparser
is
not
None
and
fparser
.
has_section
(
settings
[
"
profile
"
]):
settings
.
update
(
fparser
.
items
(
settings
[
"
profile
"
]))
del
settings
[
"
profile
"
]
# parse env
if
"
CC_SERVER
"
in
os
.
environ
:
settings
[
"
server
"
]
=
os
.
environ
[
"
CC_SERVER
"
]
if
"
CC_PORT
"
in
os
.
environ
:
settings
[
"
port
"
]
=
os
.
environ
[
"
CC_PORT
"
]
if
"
CC_LOGIN
"
in
os
.
environ
:
settings
[
"
login
"
]
=
os
.
environ
[
"
CC_LOGIN
"
]
if
"
CC_PASS
"
in
os
.
environ
:
settings
[
"
pass
"
]
=
os
.
environ
[
"
CC_PASS
"
]
# Early debug loading
if
"
CC_DEBUG
"
in
os
.
environ
:
settings
[
"
debug
"
]
=
"
True
"
cccli
.
debug
=
True
# load env profile
if
"
CC_PROFILE
"
in
os
.
environ
:
if
fparser
is
not
None
and
fparser
.
has_section
(
os
.
environ
[
"
CC_PROFILE
"
]):
settings
.
update
(
fparser
.
items
(
os
.
environ
[
"
CC_PROFILE
"
]))
# load a printer
printer
=
Printer
(
False
)
# Parse line argument
oparser
=
optparse
.
OptionParser
(
usage
=
"
usage: %prog [options] [commands]
"
,
...
...
@@ -86,19 +58,56 @@ try:
help
=
"
History max entry count
"
)
(
options
,
args
)
=
oparser
.
parse_args
()
# options handling
# try loading profiles
try
:
# parse profile file
propath
=
"
%s/profile
"
%
BaseDirectory
.
save_config_path
(
cccli
.
canonical_name
)
fparser
=
ConfigParser
.
RawConfigParser
()
fparser
.
read
(
propath
)
# load default profile
if
fparser
.
has_section
(
"
cli
"
):
settings
.
update
(
fparser
.
items
(
"
cli
"
))
# load next profile from cli profile
if
"
profile
"
in
settings
:
if
fparser
.
has_section
(
settings
[
"
profile
"
]):
settings
.
update
(
fparser
.
items
(
settings
[
"
profile
"
]))
del
settings
[
"
profile
"
]
else
:
printer
.
warn
(
"
Unable to load profile %s
"
%
settings
[
"
profile
"
])
# load env profile
if
"
CC_PROFILE
"
in
os
.
environ
:
if
fparser
.
has_section
(
os
.
environ
[
"
CC_PROFILE
"
]):
settings
.
update
(
fparser
.
items
(
os
.
environ
[
"
CC_PROFILE
"
]))
else
:
printer
.
warn
(
"
Unable to load profile %s
"
%
os
.
environ
[
"
CC_PROFILE
"
])
# load argline profile
if
options
.
profile
:
if
fparser
.
has_section
(
options
.
profile
):
settings
.
update
(
fparser
.
items
(
options
.
profile
))
else
:
printer
.
warn
(
"
Unable to load profile %s
"
%
option
.
profile
)
except
Exception
as
e
:
if
cccli
.
debug
:
raise
pass
# Load environment variables
if
"
CC_SERVER
"
in
os
.
environ
:
settings
[
"
server
"
]
=
os
.
environ
[
"
CC_SERVER
"
]
if
"
CC_PORT
"
in
os
.
environ
:
settings
[
"
port
"
]
=
os
.
environ
[
"
CC_PORT
"
]
if
"
CC_LOGIN
"
in
os
.
environ
:
settings
[
"
login
"
]
=
os
.
environ
[
"
CC_LOGIN
"
]
if
"
CC_PASS
"
in
os
.
environ
:
settings
[
"
pass
"
]
=
os
.
environ
[
"
CC_PASS
"
]
# Load command line options
for
i
in
[
x
.
dest
for
x
in
oparser
.
option_list
if
x
.
dest
]:
if
hasattr
(
options
,
i
):
o
=
getattr
(
options
,
i
)
if
o
:
settings
[
i
]
=
o
# load argline profile
if
"
profile
"
in
settings
:
if
fparser
is
not
None
and
fparser
.
has_section
(
settings
[
"
profile
"
]):
settings
.
update
(
fparser
.
items
(
settings
[
"
profile
"
]))
del
settings
[
"
profile
"
]
# debug stuff
if
"
debug
"
in
settings
:
cccli
.
debug
=
bool
(
settings
[
"
debug
"
])
...
...
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