|
31 | 31 | token = opts[:token] || ask('token') |
32 | 32 |
|
33 | 33 | opts = options.merge(global_options) |
34 | | - GoodData.connect(opts) |
| 34 | + client = GoodData.connect(opts) |
35 | 35 | project = GoodData::Command::Project.create( |
36 | 36 | :title => title, |
37 | 37 | :summary => summary, |
38 | 38 | :template => template, |
39 | | - :token => token |
40 | | - ) |
41 | | - puts "Project '#{project.title}' with id #{project.uri} created successfully!" |
| 39 | + :token => token, |
| 40 | + client: client) |
| 41 | + puts "Project '#{project.title}' with id #{project.pid} created successfully!" |
42 | 42 | end |
43 | 43 | end |
44 | 44 |
|
|
47 | 47 | delete.action do |global_options, options, args| |
48 | 48 | id = global_options[:project_id] |
49 | 49 | opts = options.merge(global_options) |
50 | | - GoodData.connect(opts) |
51 | | - GoodData::Command::Project.delete(id) |
| 50 | + client = GoodData.connect(opts) |
| 51 | + GoodData::Command::Project.delete(id, opts.merge(client: client)) |
52 | 52 | end |
53 | 53 | end |
54 | 54 |
|
|
73 | 73 | opts[:auth_token] = token |
74 | 74 | fail 'You have to provide a token for creating a project. Please use parameter --token' if token.nil? || token.empty? |
75 | 75 |
|
76 | | - GoodData.connect(opts) |
77 | | - new_project = GoodData::Command::Project.clone(id, opts) |
| 76 | + client = GoodData.connect(opts) |
| 77 | + new_project = GoodData::Command::Project.clone(id, opts.merge(client: client)) |
78 | 78 | puts "Project with title \"#{new_project.title}\" was cloned with id #{new_project.pid}" |
79 | 79 | end |
80 | 80 | end |
|
92 | 92 | fail 'Role name has to be provided' if role.nil? || role.empty? |
93 | 93 |
|
94 | 94 | msg = args[2] |
95 | | - msg = GoodData::Command::Project::DEFAULT_INVITE_MESSAGE if msg.nil? || msg.empty? |
| 95 | + msg = GoodData::Project::DEFAULT_INVITE_MESSAGE if msg.nil? || msg.empty? |
96 | 96 |
|
97 | 97 | opts = options.merge(global_options) |
98 | | - GoodData.connect(opts) |
| 98 | + client = GoodData.connect(opts) |
99 | 99 |
|
100 | | - GoodData::Command::Project.invite(project_id, email, role, msg) |
| 100 | + GoodData::Command::Project.invite(project_id, email, role, msg, opts.merge(client: client)) |
101 | 101 | end |
102 | 102 | end |
103 | 103 |
|
104 | 104 | c.desc 'List users' |
105 | 105 | c.command :users do |list| |
106 | 106 | list.action do |global_options, options, args| |
107 | 107 | opts = options.merge(global_options) |
108 | | - GoodData.connect(opts) |
| 108 | + client = GoodData.connect(opts) |
109 | 109 |
|
110 | 110 | pid = global_options[:project_id] |
111 | 111 | fail 'Project ID has to be provided' if pid.nil? || pid.empty? |
112 | 112 |
|
113 | | - user_list = GoodData::Command::Project.users(pid) |
114 | | - puts user_list.map { |u| [u[:last_name], u[:first_name], u[:login], u[:uri]].join(',') } |
| 113 | + user_list = GoodData::Command::Project.users(pid, opts.merge(client: client)) |
| 114 | + puts user_list.map { |u| [u.last_name, u.first_name, u.login, u.uri].join(',') } |
115 | 115 | end |
116 | 116 | end |
117 | 117 |
|
|
120 | 120 | show.action do |global_options, options, args| |
121 | 121 | id = global_options[:project_id] |
122 | 122 | opts = options.merge(global_options) |
123 | | - GoodData.connect(opts) |
124 | | - p = GoodData::Command::Project.show(id) |
| 123 | + client = GoodData.connect(opts) |
| 124 | + p = GoodData::Command::Project.show(id, client: client) |
125 | 125 | pp p.data |
126 | 126 | end |
127 | 127 | end |
|
130 | 130 | c.command :build do |show| |
131 | 131 | show.action do |global_options, options, args| |
132 | 132 | opts = options.merge(global_options) |
133 | | - GoodData.connect(opts) |
| 133 | + client = GoodData.connect(opts) |
134 | 134 | spec, _ = GoodData::Command::Project.get_spec_and_project_id('.') |
135 | | - new_project = GoodData::Command::Project.build(opts.merge(:spec => spec)) |
| 135 | + new_project = GoodData::Command::Project.build(opts.merge(spec: spec, client: client)) |
136 | 136 | puts "Project was created. New project PID is #{new_project.pid}, URI is #{new_project.uri}." |
137 | 137 | end |
138 | 138 | end |
|
151 | 151 | end |
152 | 152 | end |
153 | 153 |
|
154 | | - c.desc 'Roles' |
| 154 | + c.desc 'Shows roles in the project' |
155 | 155 | c.command :roles do |roles| |
156 | 156 | roles.action do |global_options, options, args| |
157 | 157 | project_id = global_options[:project_id] |
158 | 158 | fail 'Project ID has to be provided' if project_id.nil? || project_id.empty? |
159 | 159 |
|
160 | 160 | opts = options.merge(global_options) |
161 | | - GoodData.connect(opts) |
| 161 | + client = GoodData.connect(opts) |
162 | 162 |
|
163 | | - roles = GoodData::Command::Project.roles(project_id) |
164 | | - |
165 | | - puts roles.map { |r| [r['url'], r['role']['projectRole']['meta']['title']].join(',') } |
| 163 | + roles = GoodData::Command::Project.roles(project_id, client: client) |
| 164 | + puts roles.map { |r| [r.uri, r.title].join(',') } |
166 | 165 | end |
167 | 166 | end |
168 | 167 |
|
169 | | - c.desc 'You can run project validation which will check RI integrity and other problems.' |
| 168 | + c.desc 'You can run project validation which will check RI and other problems.' |
170 | 169 | c.command :validate do |show| |
171 | 170 | show.action do |global_options, options, args| |
172 | 171 | opts = options.merge(global_options) |
173 | | - GoodData.connect(opts) |
174 | | - pp GoodData::Command::Project.validate(global_options[:project_id]) |
| 172 | + client = GoodData.connect(opts) |
| 173 | + pp GoodData::Command::Project.validate(global_options[:project_id], opts.merge(client: client)) |
175 | 174 | end |
176 | 175 | end |
177 | 176 | end |
|
0 commit comments