public static SnapshotTaken TakeSnapshot(string name, IEnumerable <string> includedPaths, IEnumerable <string> excludedNames, bool verbose) { var recorder = new SnapshotTaken(name, includedPaths, excludedNames ?? new String[0], verbose); recorder.Take(); return(recorder); }
public void View( [Required] [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")] string[] include, [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")] [Aliases("x")] string[] exclude ) { var snapshot = SnapshotTaken.TakeSnapshot("ActualSnapshot", include, exclude ?? new string[0], _verbose); Console.WriteLine("Actual snapshot contains:"); foreach (var serializerInfo in snapshot.Snapshot.DefaultSerializers.OrderBy(item => item.TypeFullName)) { Console.WriteLine("{0} => {1}[{2}]", serializerInfo.TypeFullName, serializerInfo.PackformatName, serializerInfo.Version); } }
public void Add( [Required] [Description("The name of the snapshot")] string name, [Required] [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")] string[] include, [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")] [Aliases("x")] string[] exclude, [Description("If specified the snapshot won't be saved to the snapshot file.")] [DefaultValue(false)] bool whatif, [Description("If specified the snapshot will replace an existing one with the same name (Use only in special cases to fixup messed snapshots).")] [DefaultValue(false)] bool replace) { var path = GetSnapshotPath(); var snapshotHistory = System.IO.File.Exists(path) ? SnapshotHistory.LoadFrom(path) : SnapshotHistory.Empty; var snapshot = SnapshotTaken.TakeSnapshot(name, include, exclude ?? new string[0], _verbose); Console.WriteLine("Assemblies parsed:"); snapshot.AssembliesParsed.ForEach(Console.WriteLine); if (replace) { snapshotHistory.ReplaceSnapshot(snapshot.Snapshot); } else { snapshotHistory.AddSnapshot(snapshot.Snapshot); } if (!whatif) { snapshotHistory.SaveTo(path); Console.WriteLine("Snapshot taken."); } }
public void Compare( [Required] [Description("Comma separated list of files to be parsed during snapshot creation. Wildcards are accepted.")] string[] include, [Description("Comma separated list of files to be excluded during snapshot creation. Only specify file names, not paths. Wildcards are accepted.")] [Aliases("x")] string[] exclude, [Description("Defines the name of the oldest snapshot taken into account.")] string oldestSnapshot, [Description("Returns with exit code 1 if there is a difference between the snapshots.")] [Aliases("failOnDifference")] bool haltOnDifference) { var path = GetSnapshotPath(); if (!System.IO.File.Exists(path)) { throw new ApplicationException(String.Format("Snapshot file on path {0} not found.", path)); } var history = SnapshotHistory.LoadFrom(path); var snapshot = SnapshotTaken.TakeSnapshot("ActualSnapshot", include, exclude ?? new string[0], _verbose); var snapshotsToCheckAgainst = oldestSnapshot != null ? history.SkipWhile(snp => !snp.Name.Equals(oldestSnapshot, StringComparison.InvariantCultureIgnoreCase)) : history; var difference = snapshot.Snapshot.CompareToBase(snapshotsToCheckAgainst); Console.WriteLine("The following differences are detected:"); Console.WriteLine(difference.GetHumanReadableResult(_verbose)); if (haltOnDifference) { Environment.Exit(1); } }