Skip to content

Commit

Permalink
added python modules and isModule to schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Brendan Falk committed May 3, 2021
1 parent 6dcc5e4 commit b4ff145
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 0 deletions.
9 changes: 9 additions & 0 deletions dev/python.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,14 @@ export const completionSpec: Fig.Spec = {
isCommand: true,
},
},
{
name: ["-m"],
description: "module",
args: {
name: "python module",
isModule: "python/",
suggestions: ["http.server"],
},
},
],
};
33 changes: 33 additions & 0 deletions dev/python/http.server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { SIGUNUSED } from "node:constants";

export const completion: Fig.Spec = {
name: "http.server",
description: "",
subcommands: [],
options: [
{
name: ["-d", "--directory"],
description: "Choose the directory to initiate the server from",
args: {
template: "folders",
},
},
{
name: ["-b", "--bind"],
description: "Bind to a specific IP address",
args: {
name: "IP Address",
description: "e.g. 127.0.0.1",
},
},
{
name: "--cgi",
description: "Enable the CGIHTTPRequestHandler",
},
],
// Only uncomment if http.server takes an argument
args: {
name: "port",
description: "port number",
},
};
7 changes: 7 additions & 0 deletions schemas/fig.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ declare namespace Fig {
* `time` and `builtin` have only one argument and this argument has the `isCommand` property. If I type `time git`, Fig will load up the git completion spec because the isCommand property is set.
*/
isCommand?: boolean;
/**
* Exactly the same as isCommand, except, you specify a string to preprend to what the user inputs and fig will load the completion spec accordingly. if isModule: "python/", Fig would load up the python/USER_INPUT.js completion spec from the ~/.fig/autocomplete
*
* @example
* For `python -m`, the user can input a specific module such as http.server. Each module is effectively a mini CLI tool that should have its own completions. Therefore the argument object for -m has `isModule: "python/"`. Whatever the modules user inputs, Fig will look under the `~/.fig/autocomplete/python/` directory for completion spec.
*/
isModule?: string;
/**
* Exactly the same as the `isCommand` prop except Fig will look for a completion spec in a .fig folder in the user's current working directory.
*
Expand Down
9 changes: 9 additions & 0 deletions specs/python.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ var completionSpec = {
isCommand: true,
},
},
{
name: ["-m"],
description: "module",
args: {
name: "python module",
isModule: "python/",
suggestions: ["http.server"],
},
},
],
};

32 changes: 32 additions & 0 deletions specs/python/http.server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var completionSpec = {
name: "http.server",
description: "",
subcommands: [],
options: [
{
name: ["-d", "--directory"],
description: "Choose the directory to initiate the server from",
args: {
template: "folders",
},
},
{
name: ["-b", "--bind"],
description: "Bind to a specific IP address",
args: {
name: "IP Address",
description: "e.g. 127.0.0.1",
},
},
{
name: "--cgi",
description: "Enable the CGIHTTPRequestHandler",
},
],
// Only uncomment if http.server takes an argument
args: {
name: "port",
description: "port number",
},
};

0 comments on commit b4ff145

Please sign in to comment.