Skip to content

Added support for -y - #2553

Merged
ivan-hc merged 1 commit into
ivan-hc:devfrom
vishnu350:main
Aug 10, 2026
Merged

Added support for -y#2553
ivan-hc merged 1 commit into
ivan-hc:devfrom
vishnu350:main

Conversation

@vishnu350

@vishnu350 vishnu350 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

This is a PR for AM with support for -y. Just add '-y' as the first command, it will auto-choose "Y" for Y/N questions, or an empty string for the others.

Echo will no longer be needed for using am/appman inside scripts, it will behave more closely like existing distro package managers (eg. apt -y ...).

Methodology:

  1. Updated parsing to check for -y and then use "shift" to remove it.
  2. Added a _read function to wrap the actual read function:
    • Provides a default "Y" if the read variable name is $yn.
    • Provides a default "1" if the read variable name is $choice.
    • Provides a default "" (empty string) if variable name is anything else.
  3. Only changed APP-MANAGER, modules/management.am, and modules/install.am.

Example usage:

  • To uninstall apps: am -y -r app
  • Switch to appman: am -y --user
  • Lock/unlock app: am -y lock app
  • Translate: am -y --translate
  • It also works during first run: am -y or appman -y

@ivan-hc

ivan-hc commented Aug 6, 2026

Copy link
Copy Markdown
Owner

To uninstall apps: am -y -i gimp
Switch back to am: am -y --system

???

They don't need confirm. Also, -i is for installations. This is a typo.

@vishnu350

vishnu350 commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Fixed the typo, sorry.

It is basically confirmation-less mode feature. Its a global switch, should work for all read calls wherever needed.

Since your original code already has default handling if the string is empty, this works quite nicely.

@ivan-hc

ivan-hc commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Convert this to a draft if this is still a draft.

Later, I want involve other cooperators to review this. Thanks.

@vishnu350

Copy link
Copy Markdown
Contributor Author

OK, its ready for review.

@ivan-hc

ivan-hc commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Please @fiftydinar @cheack @Samueru-sama want to review this?

Comment thread APP-MANAGER
printf $"Zsh completion requires editing the main configuration file, but it may cause problems.\nSee https://github.com/ivan-hc/AM/issues/1843\n" | _fit
read -r -p $"Want to proceed anyway? (y,N)" response
if echo "$response" | grep -qi "^y"; then
_read $"Want to proceed anyway? (y,N)" yn

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the variable name has to be yn for the _read function to automatically give Y:

	if [[ "$default_yes" == true ]]; then
		# If variable name is 'yn', default to 'y'
		if [[ "$var_name" == "yn" ]]; then
			results="y"
		fi
	else
		read -r -ep "$prompt" results
	fi

@ivan-hc

ivan-hc commented Aug 9, 2026

Copy link
Copy Markdown
Owner

@vishnu350 by merging #2565 I have added conflicts

@vishnu350

Copy link
Copy Markdown
Contributor Author

Merge and made cleanups, please check. Just search for "_read " or "read -" to find the changed lines.

The _read function to wrapper does the following:

  • Provides a default "Y" if the read variable name is $yn.
  • Provides a default "1" if the read variable name is $choice.
  • Provides a default "" (empty string) if variable name is anything else.

It works nicely since AM has a default handling for empty strings, for example:

_read $" Write your choice here, or leave blank to use \"date/time\": " response

will use date+time if response is an empty string.

@ivan-hc

ivan-hc commented Aug 9, 2026

Copy link
Copy Markdown
Owner

All .po files got updated. In case of changes while reviewing, these files may be updated too and cause conflicts again.

Please disable workflows in your fork.

@ivan-hc

ivan-hc commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Out of these, there are three references to "Type a number and press ENTER:" I made translatable in #2573

@vishnu350

Copy link
Copy Markdown
Contributor Author

Should I close and redo? The web-flow has made a mess.

1. Updated parsing to check for -y and then use "shift" to remove it.
2. Added a _read function to wrap the actual read function:
   - Provides a default "Y" if the read variable name is $yn.
   - Provides a default "1" if the read variable name is $choice.
   - Provides a default "" (empty string) if variable name is anything else.
@vishnu350 vishnu350 reopened this Aug 9, 2026
@ivan-hc
ivan-hc changed the base branch from main to dev August 10, 2026 01:04
@ivan-hc

ivan-hc commented Aug 10, 2026

Copy link
Copy Markdown
Owner

I'm going to merge this to the dev branch, so people can test it using

am --devmode-enable
am -s

This will be the core change in AM 10.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants