Skip to content

Commit 8e06885

Browse files
authored
Merge pull request #69 from gaurav123-4/master
Purpose-Based App Suggestions #18
2 parents cf46f64 + 8e4403b commit 8e06885

9 files changed

Lines changed: 777 additions & 18 deletions

File tree

README.md

Lines changed: 60 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ archpkg-helper is designed to work across Linux distributions. While originally
3434

3535
## Features
3636

37+
- **Purpose-based App Suggestions**: Get app recommendations based on what you want to do (e.g., "video editing", "office work", "programming")
38+
- **Intelligent Query Matching**: Natural language processing to understand user intent (e.g., "apps to edit videos" → video editing)
3739
- Search for packages and generate install commands for:
3840
- pacman (Arch), AUR, apt (Debian/Ubuntu), dnf (Fedora), flatpak, snap
3941
- Cross-distro support (not limited to Arch)
@@ -134,7 +136,30 @@ After installation, the CLI is available as `archpkg`.
134136

135137
Here are some common commands for using the archpkg tool:
136138

137-
#### 1. Search for a Package
139+
#### 1. Purpose-based App Suggestions (NEW!)
140+
141+
Get app recommendations based on what you want to do:
142+
143+
```sh
144+
# Get video editing apps
145+
archpkg suggest "video editing"
146+
147+
# Get office applications
148+
archpkg suggest "office"
149+
150+
# Get programming tools
151+
archpkg suggest "coding"
152+
153+
# Natural language queries work too!
154+
archpkg suggest "apps to edit videos"
155+
archpkg suggest "programming tools"
156+
archpkg suggest "photo editing"
157+
158+
# List all available purposes
159+
archpkg suggest --list
160+
```
161+
162+
#### 2. Search for a Package
138163

139164
Search for a package across all supported package managers:
140165

@@ -145,7 +170,7 @@ archpkg search firefox
145170

146171
This command will search for the `firefox` package across multiple package managers (e.g., pacman, AUR, apt).
147172

148-
#### 2. Install a Package
173+
#### 3. Install a Package
149174

150175
Once you have identified a package, use the install command to generate the correct installation command for your system:
151176

@@ -156,7 +181,7 @@ archpkg install firefox
156181

157182
This will generate an appropriate installation command (e.g., `pacman -S firefox` for Arch-based systems).
158183

159-
#### 3. Install a Package from AUR (Arch User Repository)
184+
#### 4. Install a Package from AUR (Arch User Repository)
160185

161186
To install from the AUR specifically:
162187

@@ -167,7 +192,7 @@ archpkg install vscode --source aur
167192

168193
This installs `vscode` from the AUR.
169194

170-
#### 4. Install a Package from Pacman
195+
#### 5. Install a Package from Pacman
171196

172197
To install a package directly using pacman (e.g., on Arch Linux):
173198

@@ -176,7 +201,7 @@ archpkg install firefox --source pacman
176201
```
177202

178203

179-
#### 5. Remove a Package
204+
#### 6. Remove a Package
180205

181206
To generate commands to remove a package:
182207

@@ -294,6 +319,11 @@ Top-level layout of this repository:
294319
archpkg-helper/
295320
├── .github/ # issue templates and pull request template
296321
├── archpkg/ # Core Python package code (CLI and logic)
322+
│ ├── suggest.py # Purpose-based app suggestions module
323+
│ ├── cli.py # Main CLI interface
324+
│ └── ... # Other modules
325+
├── data/ # Data files for suggestions
326+
│ └── purpose_mapping.yaml # Purpose-to-apps mapping (community-driven)
297327
├── install.sh # One-command installer script (uses pipx)
298328
├── pyproject.toml # Build/metadata configuration
299329
├── setup.py # Packaging configuration (entry points, deps)
@@ -322,6 +352,31 @@ Contributions are welcome! Please:
322352
5. Open a Pull Request
323353

324354
Report bugs or request features via the [issue tracker](https://github.com/AdmGenSameer/archpkg-helper/issues).
355+
356+
### Contributing to Purpose Mappings
357+
358+
The purpose-based suggestions are powered by a community-driven mapping file at `data/purpose_mapping.yaml`. You can help improve the suggestions by:
359+
360+
1. **Adding new purposes**: Add new categories of applications (e.g., "security", "education", "gaming")
361+
2. **Adding more apps**: Suggest additional applications for existing purposes
362+
3. **Improving descriptions**: Add better descriptions for applications
363+
4. **Adding synonyms**: Help improve the natural language processing by adding more phrase mappings
364+
365+
To contribute:
366+
1. Edit `data/purpose_mapping.yaml` to add your suggestions
367+
2. Test your changes with `python -m archpkg.cli suggest "your-purpose"`
368+
3. Submit a Pull Request with your improvements
369+
370+
Example contribution:
371+
```yaml
372+
# Add to data/purpose_mapping.yaml
373+
security:
374+
- firejail
375+
- tor
376+
- keepassxc
377+
- veracrypt
378+
- wireshark
379+
```
325380
---
326381
327382
## 🛣️ Roadmap
3.14 KB
Binary file not shown.
17.2 KB
Binary file not shown.

archpkg/cli.py

Lines changed: 87 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from archpkg.search_dnf import search_dnf
2424
from archpkg.command_gen import generate_command
2525
from archpkg.logging_config import get_logger, PackageHelperLogger
26+
from archpkg.suggest import suggest_apps, list_purposes
2627

2728
console = Console()
2829
logger = get_logger(__name__)
@@ -316,10 +317,22 @@ def main() -> None:
316317
logger.info("Starting archpkg-helper CLI")
317318

318319
parser = argparse.ArgumentParser(description="Universal Package Helper CLI")
319-
parser.add_argument('query', type=str, nargs='*', help='Name of the software to search for')
320+
subparsers = parser.add_subparsers(dest='command', help='Available commands')
321+
322+
# Search command (default behavior)
323+
search_parser = subparsers.add_parser('search', help='Search for packages by name')
324+
search_parser.add_argument('query', type=str, nargs='*', help='Name of the software to search for')
325+
search_parser.add_argument('--aur', action='store_true', help='Prefer AUR packages over Pacman when both are available')
326+
327+
# Suggest command
328+
suggest_parser = subparsers.add_parser('suggest', help='Get app suggestions based on purpose')
329+
suggest_parser.add_argument('purpose', type=str, nargs='*', help='Purpose or use case (e.g., "video editing", "office")')
330+
suggest_parser.add_argument('--list', action='store_true', help='List all available purposes')
331+
332+
# Global arguments
320333
parser.add_argument('--debug', action='store_true', help='Enable debug logging to console')
321334
parser.add_argument('--log-info', action='store_true', help='Show logging configuration and exit')
322-
parser.add_argument('--aur', action='store_true', help='Prefer AUR packages over Pacman when both are available')
335+
323336
args = parser.parse_args()
324337

325338
# Enable debug mode if requested
@@ -342,15 +355,78 @@ def main() -> None:
342355
))
343356
return
344357

358+
# Handle different commands
359+
if args.command == 'suggest':
360+
handle_suggest_command(args)
361+
return
362+
elif args.command == 'search' or args.command is None:
363+
# Default to search behavior for backward compatibility
364+
handle_search_command(args)
365+
return
366+
else:
367+
console.print(Panel(
368+
"[red]Unknown command.[/red]\n\n"
369+
"[bold cyan]Available commands:[/bold cyan]\n"
370+
"- [cyan]archpkg search firefox[/cyan] - Search for packages by name\n"
371+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose\n"
372+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes\n"
373+
"- [cyan]archpkg --help[/cyan] - Show help information",
374+
title="Invalid Command",
375+
border_style="red"
376+
))
377+
return
378+
379+
380+
def handle_suggest_command(args) -> None:
381+
"""Handle the suggest command."""
382+
if args.list:
383+
logger.info("Listing all available purposes")
384+
list_purposes()
385+
return
386+
387+
if not args.purpose:
388+
console.print(Panel(
389+
"[red]No purpose specified.[/red]\n\n"
390+
"[bold cyan]Usage:[/bold cyan]\n"
391+
"- [cyan]archpkg suggest video editing[/cyan] - Get video editing apps\n"
392+
"- [cyan]archpkg suggest office[/cyan] - Get office applications\n"
393+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes\n"
394+
"- [cyan]archpkg suggest --help[/cyan] - Show help information",
395+
title="No Purpose Specified",
396+
border_style="red"
397+
))
398+
return
399+
400+
purpose = ' '.join(args.purpose)
401+
logger.info(f"Purpose suggestion query: '{purpose}'")
402+
403+
if not purpose.strip():
404+
logger.warning("Empty purpose query provided by user")
405+
console.print(Panel(
406+
"[red]Empty purpose query provided.[/red]\n\n"
407+
"[bold cyan]Usage:[/bold cyan]\n"
408+
"- [cyan]archpkg suggest video editing[/cyan] - Get video editing apps\n"
409+
"- [cyan]archpkg suggest office[/cyan] - Get office applications\n"
410+
"- [cyan]archpkg suggest --list[/cyan] - List all available purposes",
411+
title="Invalid Input",
412+
border_style="red"
413+
))
414+
return
415+
416+
# Display suggestions
417+
suggest_apps(purpose)
418+
419+
420+
def handle_search_command(args) -> None:
421+
"""Handle the search command (original functionality)."""
345422
if not args.query:
346423
console.print(Panel(
347424
"[red]No search query provided.[/red]\n\n"
348425
"[bold cyan]Usage:[/bold cyan]\n"
349-
"- [cyan]archpkg firefox[/cyan] - Search for Firefox\n"
350-
"- [cyan]archpkg visual studio code[/cyan] - Search for VS Code\n"
351-
"- [cyan]archpkg --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
352-
"- [cyan]archpkg --debug firefox[/cyan] - Search with debug output\n"
353-
"- [cyan]archpkg --log-info[/cyan] - Show logging configuration\n"
426+
"- [cyan]archpkg search firefox[/cyan] - Search for Firefox\n"
427+
"- [cyan]archpkg search visual studio code[/cyan] - Search for VS Code\n"
428+
"- [cyan]archpkg search --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
429+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose\n"
354430
"- [cyan]archpkg --help[/cyan] - Show help information",
355431
title="Invalid Input",
356432
border_style="red"
@@ -365,10 +441,10 @@ def main() -> None:
365441
console.print(Panel(
366442
"[red]Empty search query provided.[/red]\n\n"
367443
"[bold cyan]Usage:[/bold cyan]\n"
368-
"- [cyan]archpkg firefox[/cyan] - Search for Firefox\n"
369-
"- [cyan]archpkg visual studio code[/cyan] - Search for VS Code\n"
370-
"- [cyan]archpkg --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
371-
"- [cyan]archpkg --help[/cyan] - Show help information",
444+
"- [cyan]archpkg search firefox[/cyan] - Search for Firefox\n"
445+
"- [cyan]archpkg search visual studio code[/cyan] - Search for VS Code\n"
446+
"- [cyan]archpkg search --aur firefox[/cyan] - Prefer AUR packages over Pacman\n"
447+
"- [cyan]archpkg suggest video editing[/cyan] - Get app suggestions by purpose",
372448
title="Invalid Input",
373449
border_style="red"
374450
))

0 commit comments

Comments
 (0)