Skip to content
This repository was archived by the owner on Nov 10, 2025. It is now read-only.

Commit 452ddbb

Browse files
a bit of style refactor
1 parent 7662ca0 commit 452ddbb

File tree

3 files changed

+50
-15
lines changed

3 files changed

+50
-15
lines changed

lib/wordpress_tools/database.rb

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,22 @@ def create(db_name = "wordpress")
1818

1919
no_tasks do
2020
def create_database
21-
run_command(mysql_create_command) || error("Cannot create database '#{db_name}'. Already exists?")
21+
run_command(mysql_create_command) ||
22+
error("Cannot create database '#{db_name}'. Already exists?")
2223
end
2324

2425
def test_login
25-
run_command("#{mysql_command} --execute='QUIT'") || error("Cannot login to MySQL. Wrong credentials?")
26+
run_command("#{mysql_command} --execute='QUIT'") ||
27+
error("Cannot login to MySQL. Wrong credentials?")
2628
end
2729

2830
def mysql_create_command
29-
"#{mysql_command} --execute='CREATE DATABASE #{db_name} DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'"
31+
[
32+
mysql_command,
33+
"--execute='CREATE DATABASE ",
34+
db_name,
35+
"DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;'"
36+
].join
3037
end
3138

3239
def mysql_command

lib/wordpress_tools/shared_options.rb

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,37 @@ module SharedOptions
55
class_methods do
66
def shared_options
77
[
8-
[:force, { type: :boolean, desc: "Overwrite existing WP-CLI installation" }],
9-
[:locale, { aliases: "-l", desc: "WordPress locale", default: Configuration.for(:locale) }],
10-
[:bare, { type: :boolean, aliases: "-b", desc: "Remove default themes and plugins" }],
11-
[:admin_user, { desc: "WordPress admin user", default: Configuration.for(:admin_user) }],
12-
[:admin_email, { desc: "WordPress admin email", default: Configuration.for(:admin_email) }],
13-
[:admin_password, { desc: "WordPress admin password", default: Configuration.for(:admin_password) }],
14-
[:db_user, { desc: "MySQL database user", default: Configuration.for(:db_user) }],
15-
[:db_password, { desc: "MySQL database pasword", default: Configuration.for(:db_password) }],
16-
[:site_url, { desc: "Wordpress site URL", default: Configuration.for(:site_url) }]
8+
[:force, {
9+
type: :boolean, desc: "Overwrite existing WP-CLI installation"
10+
}],
11+
[:locale, {
12+
aliases: "-l",
13+
desc: "WordPress locale",
14+
default: Configuration.for(:locale)
15+
}],
16+
[:bare, {
17+
type: :boolean,
18+
aliases: "-b",
19+
desc: "Remove default themes and plugins"
20+
}],
21+
[:admin_user, {
22+
desc: "WordPress admin user", default: Configuration.for(:admin_user)
23+
}],
24+
[:admin_email, {
25+
desc: "WordPress admin email", default: Configuration.for(:admin_email)
26+
}],
27+
[:admin_password, {
28+
desc: "WordPress admin password", default: Configuration.for(:admin_password)
29+
}],
30+
[:db_user, {
31+
desc: "MySQL database user", default: Configuration.for(:db_user)
32+
}],
33+
[:db_password, {
34+
desc: "MySQL database pasword", default: Configuration.for(:db_password)
35+
}],
36+
[:site_url, {
37+
desc: "Wordpress site URL", default: Configuration.for(:site_url)
38+
}]
1739
]
1840
end
1941

lib/wordpress_tools/wp_cli_core.rb

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,27 @@ def installed?
3535

3636
def download
3737
info("Downloading WP-CLI...")
38-
get(download_url, download_path, verbose: false, force: true) || error("Cannot download WP-CLI")
38+
get(download_url, download_path, verbose: false, force: true) ||
39+
error("Cannot download WP-CLI")
40+
3941
success("Downloaded WP-CLI")
4042
end
4143

4244
def move
4345
info("Installing WP-CLI...")
4446
need_sudo = !File.writable?(install_dir)
45-
run_command(move_command(download_path, install_path, need_sudo)) || error("Cannot install WP-CLI in '#{install_path}'")
47+
run_command(move_command(download_path, install_path, need_sudo)) ||
48+
error("Cannot install WP-CLI in '#{install_path}'")
49+
4650
success("Installed WP-CLI in '#{install_path}'")
4751
end
4852

4953
def make_executable
5054
info("Making WP-CLI executable...")
5155
need_sudo = !File.writable?(install_dir)
52-
run_command(executable_bit_command(install_path, need_sudo)) || error("Cannot make WP-CLI executable")
56+
run_command(executable_bit_command(install_path, need_sudo)) ||
57+
error("Cannot make WP-CLI executable")
58+
5359
success("WP-CLI is now executable")
5460
end
5561

0 commit comments

Comments
 (0)