From 37ce49d15df40e7a9120181c9ae36ee90eb4e137 Mon Sep 17 00:00:00 2001 From: espie Date: Sat, 27 May 2023 09:59:51 +0000 Subject: [PATCH] - make the handling of interactive more regular by delegating the choice of the class to a separate method - zap/improve meaningless comments - mark ntogo as a focus for improvements --- usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm | 23 ++++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm index 1104e204c89..4dc96af5315 100644 --- a/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm +++ b/usr.sbin/pkg_add/OpenBSD/AddCreateDelete.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: AddCreateDelete.pm,v 1.50 2021/01/30 11:16:58 espie Exp $ +# $OpenBSD: AddCreateDelete.pm,v 1.51 2023/05/27 09:59:51 espie Exp $ # # Copyright (c) 2007-2014 Marc Espie # @@ -19,7 +19,7 @@ use strict; use warnings; -# common framework, let's place most everything in there +# common behavior to pkg_add, pkg_delete, pkg_create package OpenBSD::AddCreateDelete::State; our @ISA = qw(OpenBSD::State); @@ -62,6 +62,17 @@ sub add_interactive_options return $self; } +sub interactive_class +{ + my ($class, $i) = @_; + if ($i) { + require OpenBSD::Interactive; + return 'OpenBSD::Interactive'; + } else { + return 'OpenBSD::InteractiveStub'; + } +} + sub handle_options { my ($state, $opt_string, @usage) = @_; @@ -86,11 +97,7 @@ sub handle_options $i = -t STDIN; } } - if ($i) { - require OpenBSD::Interactive; - $state->{interactive} = OpenBSD::Interactive->new($state, $i); - } - $state->{interactive} //= OpenBSD::InteractiveStub->new($state); + $state->{interactive} = $state->interactive_class($i)->new($state, $i); } @@ -160,6 +167,7 @@ sub run_makewhatis OpenBSD::Paths->makewhatis, @$opts, '--', @$l); } +# TODO the maze of ntogo/todo/... is a mess sub ntogo { my ($self, $offset) = @_; @@ -181,7 +189,6 @@ sub ntogo_string sub solve_dependency { my ($self, $solver, $dep, $package) = @_; - # full dependency solving with everything return $solver->really_solve_dependency($self, $dep, $package); } -- 2.20.1