diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-04-02 17:27:33 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-04-03 10:44:51 -0300 |
commit | 9c03508958522b2beeaa2aa289ad82e444d902d8 (patch) | |
tree | 69ea1eab1529e55b02abe43d8b4b97cfb837a54a /src | |
parent | 0b80c36bc1dfe85c882918b30f45d3a3fdf0e5ce (diff) | |
download | luarocks-9c03508958522b2beeaa2aa289ad82e444d902d8.tar.gz luarocks-9c03508958522b2beeaa2aa289ad82e444d902d8.tar.bz2 luarocks-9c03508958522b2beeaa2aa289ad82e444d902d8.zip |
Add --global, improve relationship between project and --local
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cmd.lua | 23 | ||||
-rw-r--r-- | src/luarocks/cmd/help.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fs/lua.lua | 2 | ||||
-rw-r--r-- | src/luarocks/util.lua | 1 |
4 files changed, 18 insertions, 11 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 93bc5525..eb120c0b 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -70,9 +70,9 @@ do | |||
70 | end | 70 | end |
71 | 71 | ||
72 | process_tree_flags = function(flags, project_dir) | 72 | process_tree_flags = function(flags, project_dir) |
73 | 73 | ||
74 | if cfg.local_by_default then | 74 | if flags["global"] then |
75 | flags["local"] = true | 75 | cfg.local_by_default = false |
76 | end | 76 | end |
77 | 77 | ||
78 | if flags["tree"] then | 78 | if flags["tree"] then |
@@ -91,18 +91,23 @@ do | |||
91 | local root_dir = fs.absolute_name(flags["tree"]) | 91 | local root_dir = fs.absolute_name(flags["tree"]) |
92 | replace_tree(flags, root_dir) | 92 | replace_tree(flags, root_dir) |
93 | end | 93 | end |
94 | elseif flags["project-tree"] then | ||
95 | local tree = flags["project-tree"] | ||
96 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) | ||
97 | loader.load_rocks_trees() | ||
98 | path.use_tree(tree) | ||
99 | elseif flags["local"] then | 94 | elseif flags["local"] then |
100 | if not cfg.home_tree then | 95 | if not cfg.home_tree then |
101 | return nil, "The --local flag is meant for operating in a user's home directory.\n".. | 96 | return nil, "The --local flag is meant for operating in a user's home directory.\n".. |
102 | "You are running as a superuser, which is intended for system-wide operation.\n".. | 97 | "You are running as a superuser, which is intended for system-wide operation.\n".. |
103 | "To force using the superuser's home, use --tree explicitly." | 98 | "To force using the superuser's home, use --tree explicitly." |
99 | else | ||
100 | replace_tree(flags, cfg.home_tree) | ||
101 | end | ||
102 | elseif flags["project-tree"] then | ||
103 | local tree = flags["project-tree"] | ||
104 | table.insert(cfg.rocks_trees, 1, { name = "project", root = tree } ) | ||
105 | loader.load_rocks_trees() | ||
106 | path.use_tree(tree) | ||
107 | elseif cfg.local_by_default then | ||
108 | if cfg.home_tree then | ||
109 | replace_tree(flags, cfg.home_tree) | ||
104 | end | 110 | end |
105 | replace_tree(flags, cfg.home_tree) | ||
106 | elseif project_dir then | 111 | elseif project_dir then |
107 | local project_tree = project_dir .. "/lua_modules" | 112 | local project_tree = project_dir .. "/lua_modules" |
108 | table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) | 113 | table.insert(cfg.rocks_trees, 1, { name = "project", root = project_tree } ) |
diff --git a/src/luarocks/cmd/help.lua b/src/luarocks/cmd/help.lua index 556929c5..e5f1b799 100644 --- a/src/luarocks/cmd/help.lua +++ b/src/luarocks/cmd/help.lua | |||
@@ -45,7 +45,6 @@ function help.command(description, commands, command) | |||
45 | assert(type(commands) == "table") | 45 | assert(type(commands) == "table") |
46 | 46 | ||
47 | if not command then | 47 | if not command then |
48 | local conf = cfg.which_config() | ||
49 | print_banner() | 48 | print_banner() |
50 | print_section("NAME") | 49 | print_section("NAME") |
51 | util.printout("\t"..program..[[ - ]]..description) | 50 | util.printout("\t"..program..[[ - ]]..description) |
@@ -68,6 +67,7 @@ function help.command(description, commands, command) | |||
68 | --tree=<tree> Which tree to operate on. | 67 | --tree=<tree> Which tree to operate on. |
69 | --local Use the tree in the user's home directory. | 68 | --local Use the tree in the user's home directory. |
70 | To enable it, see ']]..program..[[ help path'. | 69 | To enable it, see ']]..program..[[ help path'. |
70 | --global Use the system tree when `local_by_default` is `true`. | ||
71 | --verbose Display verbose output of commands executed. | 71 | --verbose Display verbose output of commands executed. |
72 | --timeout=<seconds> Timeout on network operations, in seconds. | 72 | --timeout=<seconds> Timeout on network operations, in seconds. |
73 | 0 means no timeout (wait forever). | 73 | 0 means no timeout (wait forever). |
@@ -89,6 +89,7 @@ function help.command(description, commands, command) | |||
89 | end | 89 | end |
90 | util.printout() | 90 | util.printout() |
91 | util.printout("\tConfiguration files:") | 91 | util.printout("\tConfiguration files:") |
92 | local conf = cfg.config_files | ||
92 | util.printout("\t\tSystem : ".. dir.normalize(conf.system.file) .. " (" .. get_status(conf.system.ok) ..")") | 93 | util.printout("\t\tSystem : ".. dir.normalize(conf.system.file) .. " (" .. get_status(conf.system.ok) ..")") |
93 | if conf.user.file then | 94 | if conf.user.file then |
94 | util.printout("\t\tUser : ".. dir.normalize(conf.user.file) .. " (" .. get_status(conf.user.ok) ..")") | 95 | util.printout("\t\tUser : ".. dir.normalize(conf.user.file) .. " (" .. get_status(conf.user.ok) ..")") |
diff --git a/src/luarocks/fs/lua.lua b/src/luarocks/fs/lua.lua index 6ad2b1b8..0273cd53 100644 --- a/src/luarocks/fs/lua.lua +++ b/src/luarocks/fs/lua.lua | |||
@@ -1105,7 +1105,7 @@ function fs_lua.check_command_permissions(flags) | |||
1105 | if ok then | 1105 | if ok then |
1106 | return true | 1106 | return true |
1107 | else | 1107 | else |
1108 | if flags["local"] then | 1108 | if flags["local"] or cfg.local_by_default then |
1109 | err = err .. " \n-- please check your permissions." | 1109 | err = err .. " \n-- please check your permissions." |
1110 | else | 1110 | else |
1111 | err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local." | 1111 | err = err .. " \n-- you may want to run as a privileged user or use your local tree with --local." |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index dae9307a..aac52344 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
@@ -100,6 +100,7 @@ local supported_flags = { | |||
100 | ["force"] = true, | 100 | ["force"] = true, |
101 | ["force-fast"] = true, | 101 | ["force-fast"] = true, |
102 | ["from"] = "<server>", | 102 | ["from"] = "<server>", |
103 | ["global"] = true, | ||
103 | ["help"] = true, | 104 | ["help"] = true, |
104 | ["home"] = true, | 105 | ["home"] = true, |
105 | ["homepage"] = "\"<url>\"", | 106 | ["homepage"] = "\"<url>\"", |