Skip to content

Commit

Permalink
Update from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Jul 10, 2020
1 parent d5617b0 commit 713e5b2
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/autoinstall/auto_sequence.rb
Expand Up @@ -69,7 +69,7 @@ def run
CreateDialog("System", "general")
menus
ret = super(sequence: SEQUENCE_HASH)
Yast::UI.CloseDialog
Yast::Wizard.CloseDialog
ret
end

Expand Down
45 changes: 38 additions & 7 deletions src/lib/autoinstall/clients/autoyast.rb
Expand Up @@ -57,48 +57,57 @@ def main

turn_off_signature_checks

@cmdline = {
cmdline = {
"id" => "autoyast",
"help" => _("AutoYaST"),
"guihandler" => fun_ref(method(:auto_sequence), "any ()"),
"actions" => {
"ui" => {
"handler" => fun_ref(
method(:run_ui),
"boolean (map <string, string>)"
),
"help" => ui_action_help
},
"file" => {
"handler" => fun_ref(
method(:run_ui),
"boolean (map <string, string>)"
),
"help" => "file operations"
"help" => file_action_help
},
"module" => {
"handler" => fun_ref(
method(:run_ui),
"boolean (map <string, string>)"
),
"help" => "module specific operations"
"help" => module_action_help
},
"list-modules" => {
"handler" => fun_ref(
method(:list_modules),
"void ()"
),
"help" => "list of known modules"
"help" => list_modules_action_help
}
},
"options" => {
"filename" => { "type" => "string", "help" => "filename=XML_PROFILE" },
"modname" => { "type" => "string", "help" => "modname=AYAST_MODULE" }
},
"mappings" => {
"ui" => ["filename", "modname"],
"file" => ["filename", "modname"],
"module" => ["filename", "modname"]
}
}

ret = Yast::CommandLine.Run(@cmdline)
ret = Yast::CommandLine.Run(cmdline)
log.debug("ret = #{ret}")

Yast::AddOnProduct.CleanModeConfigSources
:exit

nil
end

# Run the main UI
Expand Down Expand Up @@ -136,7 +145,7 @@ def import_profile(filename)
_(
"Error while parsing the control file.\n" \
"Check the log files for more details or fix the\n" \
"control file and try again.\n"
"AutoYaST profile and try again.\n"
)
)
end
Expand Down Expand Up @@ -191,6 +200,28 @@ def turn_off_signature_checks
)
)
end

# @return [String]
def file_action_help
_("File specific operations (deprecated). Use 'ui' action with the 'filename' " \
"option instead.")
end

# @return [String]
def module_action_help
_("Module specific operations (deprecated). Use 'ui' action instead with the " \
"'modname' option instead.")
end

# @return [String]
def ui_action_help
_("Opens the AutoYaST UI.")
end

# @return [String]
def list_modules_action_help
_("List known modules.")
end
end
end
end
15 changes: 10 additions & 5 deletions src/lib/autoinstall/clients/clone_system.rb
Expand Up @@ -65,7 +65,7 @@ def main

if [NilClass, Hash].any? { |c| Yast::WFM.Args.first.is_a?(c) }
params = Yast::WFM.Args.first || {}
doClone(params)
clone_system(params)
else
cmdline = {
"id" => "clone_system",
Expand All @@ -75,7 +75,7 @@ def main
"actions" => {
"modules" => {
"handler" => fun_ref(
method(:doClone),
method(:clone_system),
"boolean (map <string, any>)"
),
"help" => format(_("known modules: %s"), modules_list),
Expand All @@ -85,7 +85,9 @@ def main
"options" => {
"clone" => {
"type" => "string",
"help" => _("comma separated list of modules to clone")
"help" => _(
"Comma separated list of modules to clone. By default, all modules are cloned."
)
},
"filename" => {
"type" => "string",
Expand All @@ -104,8 +106,11 @@ def main
# @return [String] Default filename to write the profile to
DEFAULT_FILENAME = "/root/autoinst.xml".freeze

def doClone(options = DEFAULT_FILENAME)
filename = options["filename"] || "/root/autoinst.xml"
# Clone the system
#
# @param options [Hash] Action options
def clone_system(options)
filename = options["filename"] || DEFAULT_FILENAME

# Autoyast overwriting an already existing config file.
# The warning is only needed while calling "yast clone_system". It is not
Expand Down
6 changes: 3 additions & 3 deletions test/lib/clients/autoyast_test.rb
Expand Up @@ -41,9 +41,9 @@
Yast::Y2ModuleConfig.main
end

describe "'file' and 'module' command" do
describe "'ui' command" do
let(:path) { File.join(FIXTURES_PATH.join("profiles", "leap.xml")) }
let(:args) { ["file", "filename=#{path}"] }
let(:args) { ["ui", "filename=#{path}"] }

it "reads and imports the given profile" do
expect(Yast::WFM).to receive(:CallFunction).with("language_auto", ["Import", Hash])
Expand All @@ -68,7 +68,7 @@
end

context "when a module name is given" do
let(:args) { ["file", "modname=kdump"] }
let(:args) { ["ui", "modname=kdump"] }

it "starts the AutoYaST UI with the given module" do
expect(Yast::AutoinstConfig).to receive(:runModule=).with("kdump")
Expand Down

0 comments on commit 713e5b2

Please sign in to comment.