Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
al1-ce committed Nov 24, 2022
1 parent 18bc5e2 commit e04038d
Show file tree
Hide file tree
Showing 11 changed files with 647 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ docs/

# Code coverage
*.lst

bin/*
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "dub",
"run": false,
"cwd": "${workspaceFolder}",
"compiler": "$current",
"archType": "$current",
"buildType": "$current",
"configuration": "$current",
"problemMatcher": [
"$dmd"
],
"group": "build",
"label": "dub: Build pkm",
"detail": "dub build --compiler=dmd -a=x86_64 -b=debug -c=application"
}
]
}
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,24 @@
# pkm
Simple Yay wrapper
**P**ac**K**age**M**anager - Simple apt-style [Yay](https://github.com/Jguer/yay) wrapper

## Description

### Why?

## Installation

### Source

### Binary

### AUR

## First Use

## Commands

## Config

## FAQ

## Images
14 changes: 14 additions & 0 deletions dub.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"authors": [
"Alisa Lain"
],
"copyright": "Copyright © 2022, Alisa Lain",
"dependencies": {
"dyaml": "~>0.9.2"
},
"description": "Simple Yay wrapper",
"license": "MIT License",
"name": "pkm",
"targetName": "pkm",
"targetPath": "bin"
}
7 changes: 7 additions & 0 deletions dub.selections.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"fileVersion": 1,
"versions": {
"dyaml": "0.9.2",
"tinyendian": "0.2.0"
}
}
113 changes: 113 additions & 0 deletions src/pkm/app.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import std.stdio;
import std.getopt;
import std.array: popFront, join;
import std.process: execute, environment, executeShell, Config, spawnProcess, wait;

import pkm.search;

import sily.getopt;

// --aur -a
// --no-aur
// --version -v
// --help -h
// search | yay -Ss term
// list | yay -Q
// info | yay -Qi
// install | yay -S term
// reinstall | yay -R & yay -S
// remove | yay -R term
// checkupdates | yay -Qu
// update | yay -Sy
// upgrade | yay -Su
// clone
// build
// clean | yay -Yc
// -- custom --
// stats | yay -Ps
// pkgbuild | yay -G term | yay -Gp term

private const string _version = "pkm v1.0.0";

int main(string[] args) {
version(Windows) {
writefln("Unable to run on windows.");
return 1;
}

bool optVersion = false;
bool optAur = false;

auto help = getopt(
args,
config.bundling, config.passThrough,
"version", "print version", &optVersion,
"aur|a", "search only aur", &optAur
);

Commands[] coms = [
Commands("search", "[option] <package(s)>"),
Commands("list", "[option]"),
Commands("info", "[option] <package(s)>"),
Commands("install", "[option] <package(s)>"),
// Commands("reinstall", "[option] <package(s)>"),
Commands("remove", "[option] <package(s)>"),
Commands("checkupdates", "[option]"),
Commands("update", "[option] <package(s)>"),
Commands("upgrade", "[option] <package(s)>"),
Commands("clean", "[option]"),
Commands("stats", "[option]"),
Commands("pkgbuild", "[option] <package(s)>"),
];

if (optVersion) {
writeln(_version);
return 0;
}

if (help.helpWanted || args.length == 1) {
printGetopt("", "pkm <operation> [...]", coms, help.options);
return 0;
}

string yay = "/usr/bin/yay";

string[] ops = args.dup;
ops.popFront(); // removes [0] command
ops.popFront(); // removes 'command'

if (optAur) {
ops ~= ["--aur"];
}

switch (args[1]) {
case "search":
return search(ops);
case "list":
return wait(spawnProcess([yay, "-Q"]));
case "info":
return wait(spawnProcess([yay, "-Qi"] ~ ops));
case "install":
return wait(spawnProcess([yay, "-S"] ~ ops));
// case "reinstall":
// return wait(spawnProcess([yay, "-R"] ~ ops));
// return wait(spawnProcess([yay, "-S"] ~ ops));
case "remove":
return wait(spawnProcess([yay, "-R"] ~ ops));
case "checkupdates":
return wait(spawnProcess([yay, "-Qu"] ~ ops));
case "update":
return wait(spawnProcess([yay, "-Sy"] ~ ops));
case "upgrade":
return wait(spawnProcess([yay, "-Su"] ~ ops));
case "clean":
return wait(spawnProcess([yay, "-Yc"]));
case "stats":
return wait(spawnProcess([yay, "-Ps"]));
case "pkgbuild":
return wait(spawnProcess([yay, "-Gp"] ~ ops));
default:
writefln("Unknown command \"%s\".", args[1]);
return 1;
}
}
29 changes: 29 additions & 0 deletions src/pkm/package.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module pkm.pkg;

// repo
// name
// version
// (size (package size, installed size) | aur-votes (votes, popularity))
// [group]?
// (orphaned)
// (outofdate)
// (installed: (version)) \n
// (description)

struct Pkg {
string repo = "aur";
string name = "Package";
string ver = "v0.0.0";
string pkgsize = "0 KB"; // not aur
string inssize = "0 KB";
string group = ""; // community only
bool isOrphaned = false;
bool isOutdated = false;
string outdatedDate = "";
bool isInstalled = false;
string installedVersion = "";
string description = "";

alias aurvotes = pkgsize; // aur
alias aurpopul = inssize;
}
Loading

0 comments on commit e04038d

Please sign in to comment.