1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-06-26 04:00:43 +03:00

Support for settings files in Inform and Inbuild

This commit is contained in:
Graham Nelson 2020-02-11 10:29:10 +00:00
parent e91d0e73f7
commit 62aa1026ae
4 changed files with 37 additions and 17 deletions

View file

@ -123,6 +123,8 @@ int main(int argc, char **argv) {
if (LinkedLists::len(unsorted_nest_list) == 0)
SharedCLI::add_nest(
Pathnames::from_text(I"inform7/Internal"), INTERNAL_NEST_TAG);
CommandLine::play_back_log();
SharedCLI::optioneering_complete();
inbuild_nest_list = SharedCLI::nest_list();

View file

@ -123,6 +123,15 @@ int SharedCLI::set_I7_source(text_stream *loc) {
int SharedCLI::set_I7_bundle(text_stream *loc) {
if (Str::len(project_bundle_request) > 0) return FALSE;
project_bundle_request = Str::duplicate(loc);
pathname *pathname_of_bundle = Pathnames::from_text(project_bundle_request);
pathname *materials = SharedCLI::pathname_of_materials(pathname_of_bundle);
TEMPORARY_TEXT(leaf);
WRITE_TO(leaf, "%s-settings.txt", INTOOL_NAME);
filename *expert_settings = Filenames::in_folder(materials, leaf);
LOG("Speculatively %f\n", expert_settings);
if (TextFiles::exists(expert_settings))
CommandLine::also_read_file(expert_settings);
DISCARD_TEXT(leaf);
return TRUE;
}
@ -142,8 +151,6 @@ void SharedCLI::create_shared_project(void) {
Filenames::in_folder(
Pathnames::subfolder(pathname_of_bundle, I"Source"),
I"story.ni");
if (Str::includes(project_bundle_request, I"#2oetMiq9bqxoxY"))
Kits::request(I"BasicInformKit");
}
if (Str::len(project_file_request) > 0) {
filename_of_i7_source = Filenames::from_text(project_file_request);
@ -160,22 +167,10 @@ void SharedCLI::create_shared_project(void) {
Projects::set_source_filename(shared_project, filename_of_i7_source);
}
@ The materials folder sits alongside the project folder and has the same name,
but ending |.materials| instead of |.inform|.
@<Create the materials nest@> =
pathname *materials = NULL;
if (pathname_of_bundle) {
TEMPORARY_TEXT(mf);
WRITE_TO(mf, "%S", Pathnames::directory_name(pathname_of_bundle));
int i = Str::len(mf)-1;
while ((i>0) && (Str::get_at(mf, i) != '.')) i--;
if (i>0) {
Str::truncate(mf, i);
WRITE_TO(mf, ".materials");
}
materials = Pathnames::subfolder(Pathnames::up(pathname_of_bundle), mf);
DISCARD_TEXT(mf);
materials = SharedCLI::pathname_of_materials(pathname_of_bundle);
Pathnames::create_in_file_system(materials);
} else if (filename_of_i7_source) {
materials = Pathnames::from_text(I"inform.materials");
@ -191,9 +186,29 @@ inform_project *SharedCLI::project(void) {
return shared_project;
}
@ The materials folder sits alongside the project folder and has the same name,
but ending |.materials| instead of |.inform|.
=
pathname *SharedCLI::pathname_of_materials(pathname *pathname_of_bundle) {
TEMPORARY_TEXT(mf);
WRITE_TO(mf, "%S", Pathnames::directory_name(pathname_of_bundle));
int i = Str::len(mf)-1;
while ((i>0) && (Str::get_at(mf, i) != '.')) i--;
if (i>0) {
Str::truncate(mf, i);
WRITE_TO(mf, ".materials");
}
pathname *materials = Pathnames::subfolder(Pathnames::up(pathname_of_bundle), mf);
DISCARD_TEXT(mf);
return materials;
}
@h Command line.
We add the following switches:
@e INBUILD_CLSG
@e NEST_CLSW
@e INTERNAL_CLSW
@e EXTERNAL_CLSW
@ -204,6 +219,7 @@ We add the following switches:
=
void SharedCLI::declare_options(void) {
CommandLine::begin_group(INBUILD_CLSG);
CommandLine::declare_switch(NEST_CLSW, L"nest", 2,
L"add the nest at pathname X to the search list");
CommandLine::declare_switch(INTERNAL_CLSW, L"internal", 2,
@ -218,6 +234,7 @@ void SharedCLI::declare_options(void) {
L"work within the Inform project X");
CommandLine::declare_switch(SOURCE_CLSW, L"source", 2,
L"use file X as the Inform source text");
CommandLine::end_group();
}
void SharedCLI::option(int id, int val, text_stream *arg, void *state) {

View file

@ -4,7 +4,7 @@ PM_EnigmaticThey PM_EnigmaticPronoun PM_WordTooLong PM_TooMuchQuotedText PM_Unen
PM_BadTitleSentence PM_HeadingStopsBeforeEndOfLine PM_HeadingOverLine HEADINGS _ doc14 "2.5" "2.5. Headings"
PM_UnknownInternalTest PM_TestDoubleWith PM_TestCommandTooLong PM_TestContainsUndo PM_TestBadRequirements PM_TestDuplicate PM_TestMultiWord _ doc17 "2.8" "2.8. The TEST command"
PM_BogusExtension _ doc19 "2.10" "2.10. Installing extensions"
PM_ExtMisidentifiedEnds PM_ExtInadequateVM PM_ExtMalformedVM PM_ExtMisidentified PM_ExtMiswordedBeginsHere PM_ExtVersionMalformed PM_IncludeExtQuoted _ doc20 "2.11" "2.11. Including extensions"
PM_ExtMisidentifiedEnds PM_ExtInadequateVM PM_ExtMalformedVM PM_ExtMiswordedBeginsHere PM_ExtVersionMalformed PM_IncludeExtQuoted _ doc20 "2.11" "2.11. Including extensions"
OPTIONS PM_UnknownUseOption PM_UONotNumerical _ doc21 "2.12" "2.12. Use options"
OPTIONSFILE _ doc22 "2.13" "2.13. Administering classroom use"
STORYFILES PM_BadICLIdentifier _ doc23 "2.14" "2.14. Limits and the Settings panel"
@ -266,7 +266,7 @@ PM_MapPlacementDirection PM_MapPlacement PM_MapDirectionClue PM_MapHintUnknown P
EPSMAP _ doc414 "25.19" "25.19. Producing an EPS format map"
EXTENSIONS _ doc430 "27.1" "27.1. The status of extensions"
SRULES _ doc431 "27.2" "27.2. The Standard Rules"
PM_ExtNoEndsHere PM_ExtNoBeginsHere PM_ExtMultipleEndsHere PM_ExtEndsWithoutBegins PM_ExtBeginsAfterEndsHere PM_ExtMultipleBeginsHere _ doc434 "27.5" "27.5. A simple example extension"
PM_ExtNoEndsHere PM_ExtNoBeginsHere PM_ExtMultipleEndsHere PM_ExtBeginsAfterEndsHere PM_ExtMultipleBeginsHere _ doc434 "27.5" "27.5. A simple example extension"
PM_ExtNoVersion PM_ExtVersionTooLow phs_extcredits phs_compextcredits _ doc435 "27.6" "27.6. Version numbering"
PM_UnequalHeadingInPlaceOf PM_HeadingInPlaceOfUnknown PM_HeadingInPlaceOfUnincluded _ doc438 "27.9" "27.9. Extensions can interact with other extensions"
PM_ImplicationValueProperty PM_ImplicationCertain _ doc442 "27.13" "27.13. Implications"

View file

@ -180,6 +180,7 @@ list is not exhaustive.
LOG("Inform called as:");
for (int i=0; i<argc; i++) LOG(" %s", argv[i]);
LOG("\n");
CommandLine::play_back_log();
Problems::Issue::start_problems_report();
@