Skip to content

Commit

Permalink
Fix help
Browse files Browse the repository at this point in the history
  • Loading branch information
poolofthought committed Apr 20, 2018
1 parent 6995b1e commit 6670ac3
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions CSProlog/PredStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,19 +830,34 @@ public void CrossRefTableToSpreadsheet (string fileName)
public bool ShowHelp (string functor, int arity, out string suggestion)
{
suggestion = null;
const string HELPRES = "CsProlog.CsPrologHelp";
string HELPRES = "CsProlog.CsPrologHelp"; // default HELPRES

Assembly asm = Assembly.Load(new AssemblyName("CSProlog"));

//TODO: I've hardcoded the assembly name is CSProlog in Assembly.Load rather than using the AssemblyQualifiedName (was getting an error - not sure why and don't want to fight with it)
//Assembly asm = Assembly.Load(new AssemblyName(GetType().AssemblyQualifiedName));

string [] res = asm.GetManifestResourceNames (); // pick the right functor from res and put in in HELPRES
foreach (string s in res)
{
//IO.WriteLine("FunctorInGetManifestResourceNames: " + s); // uncomment to see the resources - maybe help identify which one it should be if having problmes
//Could be CSProlog.CSPrologHelp.resources OR CSProlog.Core.CSPrologHelp.resources --- the below loop should find the right one and user it
if (s.Contains("CsPrologHelp.resources"))
{
HELPRES = s.Replace(".resources", "");
break;
}
}

Assembly asm = Assembly.Load(new AssemblyName(GetType().AssemblyQualifiedName));
//string [] res = asm.GetManifestResourceNames (); // pick the right functor from res and put in in HELPRES
ResourceManager rm = new ResourceManager (HELPRES, asm);

if (functor == null)
{
IO.WriteLine (rm.GetString ("help$"));
IO.WriteLine ("\r\n (*) contains the description of a feature rather than a predicate.");
IO.WriteLine ("\r\n Usage: help <predicate>[/<arity>] or help( <predicate>[/<arity>]).");
IO.WriteLine ("\r\n File CsPrologHelp.txt contains the help texts and a description of how to re-create help.");

IO.WriteLine ("\r\n File CsPrologHelp.txt contains the help texts and a description of how to re-create help."); //TODO: I can't seem to find this file. Eliminate the line or create the file???
return true;
}
else if (functor == "history")
Expand Down

1 comment on commit 6670ac3

@poolofthought
Copy link
Collaborator Author

@poolofthought poolofthought commented on 6670ac3 Apr 20, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: If I recall, the error that this line caused was only occuring with linux / dotnetstandard. Whoever decides to change this code one test that should be double checked is that "help." predicate works in the PL.NETCore after the change.

Please sign in to comment.