1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
|
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
|
+
+
+
+
+
-
+
-
+
+
-
+
-
-
+
+
|
** If fAllowDoubleDash is true then if the flag "--" is found, it is
** removed from the list and arguments after that flag are not
** inspected by this function (they are assumed to be
** file/wiki/branch/etc. names, even if they syntactically look like
** flags). If fAllowDoubleDash is false then the "--" flag will
** trigger a fatal error exactly as if an unprocessed flag were
** encountered.
**
** Returns false (0) if fAllowDoubleDash is false or if "--" is not
** encountered. If fAllowDoubleDash is true and "--" is encountered,
** the argument index (in g.argv) at which "--" was encountered (and
** removed) is returned.
**
** Sidebar: the question of whether fAllowDoubleDash should be true or
** false would seem to boil down to: does the calling routine
** expect/allow arbitrary file/page/branch/whatever name arguments
** after its required arguments?
*/
static void verify_all_options_impl(int fAllowDoubleDash){
static int verify_all_options_impl(int fAllowDoubleDash){
int i;
for(i=1; i<g.argc; i++){
const char * arg = g.argv[i];
if( arg[0]=='-' ){
if( arg[1]=='-' && arg[2]==0 ){
if(fAllowDoubleDash){
/* Remove "--" from the list and assume any following
** arguments are file names. */
remove_from_argv(i, 1);
break;
return i;
}else{
fossil_fatal("The -- flag is not allowed here.");
}
}else if( arg[1]!=0 ){
fossil_fatal(
"unrecognized command-line option, or missing argument: %s",
arg);
}
}
}
return 0;
}
/*
** Must be called by all commands which process CLI flags, after
** consuming those flags (via find_option() and friends), to confirm
** that no unconsumed flags are still in the arguments list. If the
** command should/can honor the "--" flag, call verify_all_options2()
** instead.
*/
void verify_all_options(void){
verify_all_options_impl(0);
}
/*
** Identical to verify_all_options() except that it honors the "--"
** flag.
** flag and returns true (non-0) if that flag was encountered/consumed.
*/
void verify_all_options2(void){
verify_all_options_impl(1);
int verify_all_options2(void){
return verify_all_options_impl(1);
}
/*
** This function returns a human readable version string.
*/
const char *get_version(){
static const char version[] = RELEASE_VERSION " " MANIFEST_VERSION " "
|