-
Notifications
You must be signed in to change notification settings - Fork 45
/
Rakefile
86 lines (73 loc) · 2.22 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# frozen_string_literal: true
namespace :docs do
desc 'Serve the documentation site'
task :serve do
within_docs_directory do
unless system('bundle check')
puts "Bundler is not installed or dependencies are not met. Please run 'rake docs:install'."
exit 1
end
sh 'bundle exec jekyll s'
end
end
desc 'Install dependencies for the documentation site'
task :install do
within_docs_directory do
sh 'bundle install'
end
end
desc 'Generate usage documentation'
task :generate_usage do
output = `./bin/noir -h`
cleaned_output = output.gsub(/\e\[[0-9;]*m/, '') # Remove ANSI color codes
File.write('docs/_includes/usage.md', cleaned_output)
end
def within_docs_directory(&block)
Dir.chdir('docs', &block)
rescue Errno::ENOENT => e
puts "Directory 'docs' not found: #{e.message}"
exit 1
rescue StandardError => e
puts "An error occurred: #{e.message}"
exit 1
end
end
namespace :lint do
desc 'Format the code using crystal tool format'
task :format do
sh 'crystal tool format'
end
desc 'Lint the code using ameba'
task :ameba do
sh 'ameba --fix'
end
desc 'Run all linting tasks'
task all: %i[format ameba]
end
namespace :completion do
desc 'Check for missing flags in completion scripts'
task :check do
# Extract flags from ./bin/noir -h
noir_help_output = `./bin/noir -h`
noir_flags = noir_help_output.scan(/^\s+(-\w|--\w[\w-]*)/).flatten.uniq
# Generate completion scripts
zsh_completion = `./bin/noir --generate-completion=zsh`
bash_completion = `./bin/noir --generate-completion=bash`
fish_completion = `./bin/noir --generate-completion=fish`
# Extract flags from generated completion scripts
completion_scripts = {
'zsh' => zsh_completion,
'bash' => bash_completion,
'fish' => fish_completion
}
completion_scripts.each do |shell, content|
missing_flags = noir_flags.reject { |flag| content.include?(flag) }
if missing_flags.empty?
puts "All flags are present in the #{shell} completion script."
else
puts "Missing flags in #{shell} completion script:"
missing_flags.each { |flag| puts flag }
end
end
end
end