1. Christian Specht
  2. MissileSharp

Commits

Christian Specht  committed 120fa88 Draft

ignore comment lines in config file

  • Participants
  • Parent commits cd6b80d
  • Branches default

Comments (0)

Files changed (4)

File readme-full.md

View file
  • Ignore whitespace
 	up,500
 	fire,2
 
-You can save several of these command sets in the same file, each one under its own name (in this case, "Steve").
+You can save several of these command sets in the same file, each one under its own name (in this case, "Steve").  
+Lines beginning with `#` will be ignored and can be used for comments.
 
 First, you have to load the file once:
 

File src/MissileSharp.Demo/settings.txt

View file
  • Ignore whitespace
 up,1000
 fire,4
 
+# lines starting with "#" are comments and will be ignored
+
 [Steve]
 reset,0
 right,1000

File src/MissileSharp.Tests/Library/ConfigReaderTests.cs

View file
  • Ignore whitespace
             conf.Add(string.Empty);
             conf.Add("[name2]");
             conf.Add("right,20");
+            conf.Add("# comment");
             conf.Add("fire,2");
 
             return GetConfigFromList(conf);

File src/MissileSharp/ConfigReader.cs

View file
  • Ignore whitespace
                 {
                     key = line.Substring(1, line.Length - 2);
                 }
-                else if (line.Length > 0) // ignore empty lines
+                else if (line.Length > 0 && !line.StartsWith("#")) // ignore empty lines and #comments
                 {
                     if (string.IsNullOrEmpty(key))
                     {