add pkg alias command #324

Closed
sbz opened this Issue Aug 8, 2012 · 3 comments

3 participants

@sbz
The FreeBSD Project member
sbz commented Aug 8, 2012

Add a new command pkg alias allow to alias command in order to create user specific command.

Some examples to illustrate the new command line usage:

  • adding new aliases

% pkg alias show="info -f"
% pkg alias myshow="query '%n-%v'"

  • listing existing aliases

% pkg alias or pkg alias list
show="info -f"
myshow="query '%n-%v'"

  • using aliases

% pkg show pkgname
% pkg myshow pkgname

  • deleting alias

% pkg alias show del
% pkg alias myshow del

Alias could be serialized in the ${LOCALBASE}/etc/pkg.conf in the same manner as repos or not:

Aliases definitions

alias:
show : info -f
myshow : query '%n-%v'

Purpose is to have a behavior like {apt-cache,aptitude,...} show pkgname and more !

@infracaninophile
The FreeBSD Project member
@dnaeon

Perhaps this could be implemented as a plugin as well :)

@bapt bapt added a commit that referenced this issue Aug 26, 2013
@bapt bapt Introduce pkg alias
To use it add the following to pkg.conf:
alias:
  leaf = query -e "%a == 0" "%n-%v"

now pkg leaf will do the equivalent of:
pkg query -e "%a == 0" "%n-%v"

Fixes: #324
50239e3
@sbz
The FreeBSD Project member

I just test it after the commit 50239e3, the proper syntax of the configuration is like below (it's semi-colon instead of = in the commit log) :

alias:
leaf: query -e "%a == 0" "%n-%v"
show: info -f

(sbz@ogoshi(agent ):~/github/pkg) % pkg info -f ltrace-0.6.0
ltrace-0.6.0
Name : ltrace
Version : 0.6.0
Origin : sysutils/ltrace
Prefix : /usr/local
Categories : sysutils
Licenses : GPLv2
Maintainer : sbz@FreeBSD.org
WWW : http://ltrace.org/
Comment : Track runtime library calls in dynamically linked programs
Options :
DOCS : on
Flat size : 204KiB
Description :
ltrace intercepts and records dynamic library calls which are called by an
executed process and the signals received by that process. It can also intercept
and print the system calls executed by the program.

WWW: http://ltrace.org/
(sbz@ogoshi(agent ):~/github/pkg) % pkg show ltrace-0.6.0
ltrace-0.6.0
Name : ltrace
Version : 0.6.0
Origin : sysutils/ltrace
Prefix : /usr/local
Categories : sysutils
Licenses : GPLv2
Maintainer : sbz@FreeBSD.org
WWW : http://ltrace.org/
Comment : Track runtime library calls in dynamically linked programs
Options :
DOCS : on
Flat size : 204KiB
Description :
ltrace intercepts and records dynamic library calls which are called by an
executed process and the signals received by that process. It can also intercept
and print the system calls executed by the program.

WWW: http://ltrace.org/

And insure command output is the same

(sbz@ogoshi(agent ):~/github/pkg) % diff -ruN <(pkg info -f ltrace-0.6.0) <(pkg show ltrace-0.6.0)
(sbz@ogoshi(agent ):~/github/pkg) %

Great! For now they're justed "read only" alias I will try in next step to add a pkg alias command as a plugin to manage (read/write/delete/list) aliases for long term.

Thanks!

@sbz sbz closed this Aug 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment