/// <summary> /// Show sample C# script file. /// </summary> public void Sample(string appType, string outFile) { if (appType == null) { print?.Invoke(HelpProvider.BuildSampleHelp()); } else { foreach (var sample in HelpProvider.BuildSampleCode(appType, outFile)) { if (outFile.IsNotEmpty()) { var file = Path.GetFullPath(outFile).ChangeExtension(sample.FileExtension); print?.Invoke($"Created: {file}"); File.WriteAllText(file, sample.Code); } else { print?.Invoke($"\nsample{sample.FileExtension}:"); print?.Invoke(sample.Code); } } } }
/// <summary> /// Show sample C# script file. /// </summary> public void Sample(string appType, string outFile) { if (appType == null && outFile == null) { print?.Invoke(HelpProvider.BuildSampleHelp()); } else { var context = outFile; if (appType == "cmd") { context = outFile ?? "-new_command"; } foreach (var sample in HelpProvider.BuildSampleCode(appType, context)) { if (outFile.IsNotEmpty()) { if (appType == "cmd" && outFile.GetDirName().IsEmpty()) { // the command output file specified by command name only outFile = Runtime.CustomCommandsDir.PathJoin(outFile); } var file = Path.GetFullPath(outFile).ChangeExtension(sample.FileExtension); print?.Invoke($"Created: {file}"); File.WriteAllText(file, sample.Code); } else { print?.Invoke($"{NewLine}{context}{sample.FileExtension}:{NewLine}----------"); print?.Invoke(sample.Code); } } } }