Christian Specht avatar Christian Specht committed 120fa88 Draft

ignore comment lines in config file

Comments (0)

Files changed (4)

 	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:
 

src/MissileSharp.Demo/settings.txt

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

src/MissileSharp.Tests/Library/ConfigReaderTests.cs

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

src/MissileSharp/ConfigReader.cs

                 {
                     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))
                     {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.