natvis-join 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +28 -0
  4. data/bin/natvis-join +112 -0
  5. metadata +62 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 753804b91a3ae8116954545478dfbff09bca514d6ceae7d766fbc7dffea321cd
4
+ data.tar.gz: deed40094a5c424c5b3c533587c3607711548dde952702ac64a8486ab90712b4
5
+ SHA512:
6
+ metadata.gz: ab4b3950a6957233ef8d3859f6122927df4f3ba1826b653f75b355891362efc21c53c94597bb50bd21c877fdb6ce061f40a0942d3c59d6eb2759041e1c2bd31a
7
+ data.tar.gz: 4dea0ba568e65b760ca1c21bfb579df94a936708610ef6805a98b2e3de3f8568e8e74a8f417b3e1341f4e789c40b8beb5dd5515a4d806d0292990cc1269e6011
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Borislav Stanimirov
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,28 @@
1
+ # natvis-join
2
+
3
+ A CLI tool to join multiple .natvis files into one.
4
+
5
+ Visual Studio can be configured to use multiple .natvis files. In Visual Studio Code the plugin [vscode-cpptools](https://github.com/microsoft/vscode-cpptools) can be configured to use a single .natvis file.
6
+
7
+ This tool helps by combining multiple .natvis files into one which can then be used in Visual Studio Code.
8
+
9
+ ## Installation
10
+
11
+ A Ruby interpreter is required.
12
+
13
+ You can install the gem with `$ gem install natvis-join` or you can just copy the self-contained file `bin/natvis-join` to use as a loose script.
14
+
15
+ ## Usage
16
+
17
+ `$ natvis-join <paths> [-o <output_file>]`
18
+
19
+ * `paths` are paths on the disk. If an entry is a file, it is appended to the output. If it is a directory it's scanned (non-recursively) for .natvis files and all found are appended to the output
20
+ * `output_file` is the optional output .natvis file. If it is not provided, the result is printed to the standard output.
21
+
22
+ ## License
23
+
24
+ This software is distributed under the MIT Software License. See accompanying LICENSE file or copy [here](https://opensource.org/licenses/MIT).
25
+
26
+ Copyright &copy; 2021 [Borislav Stanimirov](http://github.com/iboB)
27
+
28
+
data/bin/natvis-join ADDED
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #
4
+ # natvis-join
5
+ # Copyright (c) 2021 Borislav Stanimirov
6
+ #
7
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
8
+ # of this software and associated documentation files (the "Software"), to
9
+ # deal in the Software without restriction, including without limitation the
10
+ # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
11
+ # sell copies of the Software, and to permit persons to whom the Software is
12
+ # furnished to do so, subject to the following conditions:
13
+ #
14
+ # The above copyright notice and this permission notice shall be included in
15
+ # all copies or substantial portions of the Software.
16
+ #
17
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22
+ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
+ # IN THE SOFTWARE.
24
+ #
25
+ require 'nokogiri'
26
+
27
+ VERSION = '0.1.0'
28
+
29
+ VERSION_TEXT = "natvis-join v#{VERSION}"
30
+
31
+ USAGE = <<USG
32
+
33
+ Usage:
34
+ natvis-join <paths> [-o <output_file>]
35
+ USG
36
+
37
+ HELP = <<HLP
38
+
39
+ Join Visual Studio native debug visualizer (.natvis) files into one
40
+
41
+ Options:
42
+
43
+ paths: Paths to files and/or directories. All files from the list
44
+ and all .natvis files from the lited directories will be
45
+ joined.
46
+
47
+ -o, --output Optional output file. Without it the output goes to STDOUT
48
+ -h, -?, --help Show this help message
49
+ -v, --version Print version
50
+
51
+ HLP
52
+
53
+ begin
54
+ raise USAGE if ARGV.empty?
55
+ case ARGV[0]
56
+ when '-v', '--version'
57
+ puts VERSION_TEXT
58
+ exit(0)
59
+ when '-h', '-?', '--help'
60
+ puts VERSION_TEXT
61
+ puts USAGE
62
+ puts HELP
63
+ exit(0)
64
+ end
65
+
66
+ output = STDOUT
67
+ paths = []
68
+
69
+ output_arg = false
70
+ ARGV.each do |arg|
71
+ if arg == '-o' || arg == '--output'
72
+ output_arg = true
73
+ next
74
+ elsif output_arg
75
+ output = File.open(arg, 'w')
76
+ output_arg = false
77
+ next
78
+ else
79
+ paths << arg
80
+ end
81
+ end
82
+
83
+ AutoVisualizer = 'AutoVisualizer'
84
+
85
+ result_doc = Nokogiri::XML <<~XML
86
+ <?xml version="1.0" encoding="utf-8"?>
87
+ <AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
88
+ </AutoVisualizer>
89
+ XML
90
+
91
+ paths.map { |p|
92
+ next p if File.file?(p)
93
+ next Dir[File.join(p, '*.natvis')] if File.directory?(p)
94
+ raise "Provided path '#{p}' was not found"
95
+ nil
96
+ }.compact.flatten.each do |f|
97
+ begin
98
+ result_doc.root.add_child(" <!-- #{f} -->")
99
+ Nokogiri::XML(File.read(f)).root.children.each do |node|
100
+ result_doc.root.add_child(node)
101
+ end
102
+ rescue
103
+ raise "Invalid xml in '#{f}'"
104
+ end
105
+ end
106
+
107
+ output.puts result_doc
108
+ rescue StandardError => e
109
+ STDERR.puts e.message
110
+ exit(1)
111
+ end
112
+
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: natvis-join
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Borislav Stanimirov
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ description: 'A CLI gem to join multiple .natvis files into one
28
+
29
+ '
30
+ email: b.stanimirov@abv.bg
31
+ executables:
32
+ - natvis-join
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - LICENSE
37
+ - README.md
38
+ - bin/natvis-join
39
+ homepage: https://github.com/iboB/natvis-join
40
+ licenses:
41
+ - MIT
42
+ metadata: {}
43
+ post_install_message:
44
+ rdoc_options: []
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: '0'
52
+ required_rubygems_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirements: []
58
+ rubygems_version: 3.1.2
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: A CLI gem to join multiple .natvis files into one
62
+ test_files: []