Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
caisar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
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
pub
caisar
Commits
ab0b6cb7
Commit
ab0b6cb7
authored
3 years ago
by
Michele Alberti
Browse files
Options
Downloads
Patches
Plain Diff
Start command line command config.
parent
9ceb4e8b
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
src/main.ml
+109
-0
109 additions, 0 deletions
src/main.ml
with
109 additions
and
0 deletions
src/main.ml
+
109
−
0
View file @
ab0b6cb7
(**************************************************************************)
(* *)
(* This file is part of Caisar. *)
(* *)
(**************************************************************************)
open
Base
open
Cmdliner
module
Format
=
Caml
.
Format
let
caisar
=
"caisar"
(* Logs. *)
let
pp_header
=
let
x
=
match
Array
.
length
Caml
.
Sys
.
argv
with
|
0
->
Caml
.(
Filename
.
basename
Sys
.
executable_name
)
|
_
->
Caml
.(
Filename
.
basename
Sys
.
argv
.
(
0
))
in
let
pp_h
ppf
style
h
=
Fmt
.
pf
ppf
"[%s][%a] "
x
Fmt
.(
styled
style
string
)
h
in
fun
ppf
(
l
,
h
)
->
let
open
Logs_fmt
in
match
l
with
|
Logs
.
App
->
Fmt
.
pf
ppf
"[%a] "
Fmt
.(
styled
app_style
string
)
x
|
Logs
.
Error
->
pp_h
ppf
err_style
(
match
h
with
None
->
"ERROR"
|
Some
h
->
h
)
|
Logs
.
Warning
->
pp_h
ppf
warn_style
(
match
h
with
None
->
"WARNING"
|
Some
h
->
h
)
|
Logs
.
Info
->
pp_h
ppf
info_style
(
match
h
with
None
->
"INFO"
|
Some
h
->
h
)
|
Logs
.
Debug
->
pp_h
ppf
debug_style
(
match
h
with
None
->
"DEBUG"
|
Some
h
->
h
)
let
setup_logs
=
let
setup_log
level
=
Fmt_tty
.
setup_std_outputs
~
style_renderer
:
`Ansi_tty
()
;
Logs
.
set_level
level
;
Logs
.
set_reporter
(
Logs_fmt
.
reporter
~
pp_header
()
)
in
Term
.(
const
setup_log
$
Logs_cli
.
level
()
)
(* Commands. *)
let
config
cmd
detect
()
=
Logs
.
debug
(
fun
m
->
m
"Command `%s'."
cmd
);
if
detect
then
Logs
.
app
(
fun
m
->
m
"Automatic detection."
)
(* Command line. *)
let
config_cmd
=
let
cmdname
=
"config"
in
let
dirvar
=
"DIR"
in
let
envs
=
[
Term
.
env_info
~
doc
:
"Absolute path to the directory containing the executable of a \
solver."
dirvar
;
]
in
let
detect
=
let
doc
=
Format
.
sprintf
"Detect solvers in
\\
$PATH (or
\\
$%s, if specified)."
dirvar
in
Arg
.(
value
&
flag
&
info
[
"d"
;
"detect"
]
~
doc
)
in
let
doc
=
Format
.
sprintf
"%s configuration."
caisar
in
let
exits
=
Term
.
default_exits
in
let
man
=
[
`S
Manpage
.
s_description
;
`P
(
Format
.
sprintf
"Handle the configuration of %s."
caisar
);
]
in
(
Term
.(
ret
(
const
(
fun
cmdname
detect
_
->
if
not
detect
then
`Help
(
`Pager
,
Some
"config"
)
else
(* TODO: Do not only check for [detect], and enable it by
default, as soon as other options are available. *)
`Ok
(
config
cmdname
true
()
))
$
const
cmdname
$
detect
$
setup_logs
))
,
Term
.
info
cmdname
~
sdocs
:
Manpage
.
s_common_options
~
envs
~
exits
~
doc
~
man
)
let
default_cmd
=
let
doc
=
"Framework for neural networks property verification and more."
in
let
sdocs
=
Manpage
.
s_common_options
in
let
man
=
[
`S
Manpage
.
s_common_options
;
`P
"These options are common to all commands."
;
`S
"MORE HELP"
;
`P
"Use `$(mname) $(i,COMMAND) --help' for help on a single command."
;
`S
Manpage
.
s_bugs
;
`P
"Email bug reports to <...>"
;
]
in
let
version
=
"0.0"
in
(
Term
.(
ret
(
const
(
fun
_
->
`Help
(
`Pager
,
None
))
$
const
()
))
,
Term
.
info
caisar
~
version
~
doc
~
sdocs
~
exits
:
Term
.
default_exits
~
man
)
let
()
=
match
Term
.(
eval_choice
default_cmd
[
config_cmd
])
with
|
`Error
_
->
Caml
.
exit
1
|
_
->
Caml
.
exit
(
if
Logs
.
err_count
()
>
0
then
1
else
0
)
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