@@ -15,7 +15,104 @@ here = File.expand_path(File.dirname __FILE__)
15
15
$LOAD_PATH << "#{ here } /../lib"
16
16
17
17
require 'annotate'
18
+ <<<<<<< HEAD
18
19
require 'annotate/parser'
20
+ =======
21
+ Annotate . bootstrap_rake
22
+
23
+ has_set_position = { }
24
+ target_action = :do_annotations
25
+ positions = %w( before top after bottom )
26
+
27
+ OptionParser . new do |opts |
28
+ opts . banner = 'Usage: annotate [options] [model_file]*'
29
+
30
+ opts . on ( '-a' , '--additional_file_patterns' , Array , "Additional file paths or globs to annotate" ) do |additional_file_patterns |
31
+ ENV [ 'additional_file_patterns' ] = additional_file_patterns
32
+ end
33
+
34
+ opts . on ( '-d' , '--delete' , 'Remove annotations from all model files or the routes.rb file' ) do
35
+ target_action = :remove_annotations
36
+ end
37
+
38
+ opts . on ( '-p' , '--position [before|top|after|bottom]' , positions ,
39
+ 'Place the annotations at the top (before) or the bottom (after) of the model/test/fixture/factory/route/serializer file(s)' ) do |p |
40
+ ENV [ 'position' ] = p
41
+ %w( position_in_class position_in_factory position_in_fixture position_in_test position_in_routes position_in_serializer ) . each do |key |
42
+ ENV [ key ] = p unless has_set_position [ key ]
43
+ end
44
+ end
45
+
46
+ opts . on ( '--pc' , '--position-in-class [before|top|after|bottom]' , positions ,
47
+ 'Place the annotations at the top (before) or the bottom (after) of the model file' ) do |p |
48
+ ENV [ 'position_in_class' ] = p
49
+ has_set_position [ 'position_in_class' ] = true
50
+ end
51
+
52
+ opts . on ( '--pf' , '--position-in-factory [before|top|after|bottom]' , positions ,
53
+ 'Place the annotations at the top (before) or the bottom (after) of any factory files' ) do |p |
54
+ ENV [ 'position_in_factory' ] = p
55
+ has_set_position [ 'position_in_factory' ] = true
56
+ end
57
+
58
+ opts . on ( '--px' , '--position-in-fixture [before|top|after|bottom]' , positions ,
59
+ 'Place the annotations at the top (before) or the bottom (after) of any fixture files' ) do |p |
60
+ ENV [ 'position_in_fixture' ] = p
61
+ has_set_position [ 'position_in_fixture' ] = true
62
+ end
63
+
64
+ opts . on ( '--pt' , '--position-in-test [before|top|after|bottom]' , positions ,
65
+ 'Place the annotations at the top (before) or the bottom (after) of any test files' ) do |p |
66
+ ENV [ 'position_in_test' ] = p
67
+ has_set_position [ 'position_in_test' ] = true
68
+ end
69
+
70
+ opts . on ( '--pr' , '--position-in-routes [before|top|after|bottom]' , positions ,
71
+ 'Place the annotations at the top (before) or the bottom (after) of the routes.rb file' ) do |p |
72
+ ENV [ 'position_in_routes' ] = p
73
+ has_set_position [ 'position_in_routes' ] = true
74
+ end
75
+
76
+ opts . on ( '--ps' , '--position-in-serializer [before|top|after|bottom]' , positions ,
77
+ 'Place the annotations at the top (before) or the bottom (after) of the serializer files' ) do |p |
78
+ ENV [ 'position_in_serializer' ] = p
79
+ has_set_position [ 'position_in_serializer' ] = true
80
+ end
81
+
82
+ opts . on ( '--w' , '--wrapper STR' , 'Wrap annotation with the text passed as parameter.' ,
83
+ 'If --w option is used, the same text will be used as opening and closing' ) do |p |
84
+ ENV [ 'wrapper' ] = p
85
+ end
86
+
87
+ opts . on ( '--wo' , '--wrapper-open STR' , 'Annotation wrapper opening.' ) do |p |
88
+ ENV [ 'wrapper_open' ] = p
89
+ end
90
+
91
+ opts . on ( '--wc' , '--wrapper-close STR' , 'Annotation wrapper closing' ) do |p |
92
+ ENV [ 'wrapper_close' ] = p
93
+ end
94
+
95
+ opts . on ( '-r' , '--routes' , "Annotate routes.rb with the output of 'rake routes'" ) do
96
+ ENV [ 'routes' ] = 'true'
97
+ end
98
+
99
+ opts . on ( '-a' , '--active-admin' , 'Annotate active_admin models' ) do
100
+ ENV [ 'active_admin' ] = 'true'
101
+ end
102
+
103
+ opts . on ( '-v' , '--version' , 'Show the current version of this gem' ) do
104
+ puts "annotate v#{ Annotate . version } " ; exit
105
+ end
106
+
107
+ opts . on ( '-m' , '--show-migration' , 'Include the migration version number in the annotation' ) do
108
+ ENV [ 'include_version' ] = 'yes'
109
+ end
110
+
111
+ opts . on ( '-k' , '--show-foreign-keys' ,
112
+ "List the table's foreign key constraints in the annotation" ) do
113
+ ENV [ 'show_foreign_keys' ] = 'yes'
114
+ end
115
+ >>>>>>> Add additional_file_paths to CLI
19
116
20
117
Annotate . bootstrap_rake
21
118
0 commit comments