mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Adapt the structure to parse the initial pip commands
This commit is contained in:
parent
982da4aa77
commit
1b82aeb6b0
7 changed files with 273 additions and 22 deletions
|
|
@ -0,0 +1,29 @@
|
|||
/**
|
||||
* Pip command constants
|
||||
*/
|
||||
export const pipInstallCommand = "install";
|
||||
export const pipUninstallCommand = "uninstall";
|
||||
export const pipListCommand = "list";
|
||||
export const pipShowCommand = "show";
|
||||
export const pipFreeze = "freeze";
|
||||
|
||||
/**
|
||||
* Gets the pip command from the arguments array
|
||||
*
|
||||
* @param {string[]} args - Command line arguments
|
||||
* @returns {string|null} The pip command or null if not found
|
||||
*/
|
||||
export function getPipCommandForArgs(args) {
|
||||
if (!args || args.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// The first non-flag argument is typically the command
|
||||
for (const arg of args) {
|
||||
if (!arg.startsWith("-")) {
|
||||
return arg;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue