@@ -124,7 +124,7 @@ updateBuiltins =
124124 InputPattern
125125 " builtins.update"
126126 []
127- I. Visible
127+ I. Hidden
128128 []
129129 ( " Adds all the builtins that are missing from this namespace, "
130130 <> " and deprecate the ones that don't exist in this version of Unison."
@@ -531,7 +531,7 @@ sfind :: InputPattern
531531sfind =
532532 InputPattern " rewrite.find" [" sfind" ] I. Visible [(" rewrite-rule definition" , Required , definitionQueryArg)] msg parse
533533 where
534- parse [q] = Input. StructuredFindI Input. FindLocal <$> parseHashQualifiedName q
534+ parse [q] = Input. StructuredFindI ( Input. FindLocal Path. empty) <$> parseHashQualifiedName q
535535 parse _ = Left " expected exactly one argument"
536536 msg =
537537 P. lines
@@ -589,40 +589,76 @@ sfindReplace =
589589 ]
590590
591591find :: InputPattern
592- find = find' " find" Input. FindLocal
592+ find = find' " find" ( Input. FindLocal Path. empty)
593593
594594findAll :: InputPattern
595- findAll = find' " find.all" Input. FindLocalAndDeps
595+ findAll = find' " find.all" ( Input. FindLocalAndDeps Path. empty)
596596
597597findGlobal :: InputPattern
598598findGlobal = find' " find.global" Input. FindGlobal
599599
600+ findIn , findInAll :: InputPattern
601+ findIn = findIn' " find-in" Input. FindLocal
602+ findInAll = findIn' " find-in.all" Input. FindLocalAndDeps
603+
604+ findIn' :: String -> (Path. Path -> Input. FindScope ) -> InputPattern
605+ findIn' cmd mkfscope =
606+ InputPattern
607+ cmd
608+ []
609+ I. Visible
610+ [(" namespace" , Required , namespaceArg), (" query" , ZeroPlus , exactDefinitionArg)]
611+ findHelp
612+ \ case
613+ p : args -> first P. text do
614+ p <- Path. parsePath p
615+ pure (Input. FindI False (mkfscope p) args)
616+ _ -> Left findHelp
617+
618+ findHelp :: P. Pretty CT. ColorText
619+ findHelp =
620+ ( P. wrapColumn2
621+ [ (" `find`" , " lists all definitions in the current namespace." ),
622+ ( " `find foo`" ,
623+ " lists all definitions with a name similar to 'foo' in the current "
624+ <> " namespace (excluding those under 'lib')."
625+ ),
626+ ( " `find foo bar`" ,
627+ " lists all definitions with a name similar to 'foo' or 'bar' in the "
628+ <> " current namespace (excluding those under 'lib')."
629+ ),
630+ ( " `find-in namespace`" ,
631+ " lists all definitions in the specified subnamespace."
632+ ),
633+ ( " `find-in namespace foo bar`" ,
634+ " lists all definitions with a name similar to 'foo' or 'bar' in the "
635+ <> " specified subnamespace."
636+ ),
637+ ( " find.all foo" ,
638+ " lists all definitions with a name similar to 'foo' in the current "
639+ <> " namespace (including one level of 'lib')."
640+ ),
641+ ( " `find-in.all namespace`" ,
642+ " lists all definitions in the specified subnamespace (including one level of its 'lib')."
643+ ),
644+ ( " `find-in.all namespace foo bar`" ,
645+ " lists all definitions with a name similar to 'foo' or 'bar' in the "
646+ <> " specified subnamespace (including one level of its 'lib')."
647+ ),
648+ ( " find.global foo" ,
649+ " lists all definitions with a name similar to 'foo' in any namespace"
650+ )
651+ ]
652+ )
653+
600654find' :: String -> Input. FindScope -> InputPattern
601655find' cmd fscope =
602656 InputPattern
603657 cmd
604658 []
605659 I. Visible
606660 [(" query" , ZeroPlus , exactDefinitionArg)]
607- ( P. wrapColumn2
608- [ (" `find`" , " lists all definitions in the current namespace." ),
609- ( " `find foo`" ,
610- " lists all definitions with a name similar to 'foo' in the current "
611- <> " namespace (excluding those under 'lib')."
612- ),
613- ( " `find foo bar`" ,
614- " lists all definitions with a name similar to 'foo' or 'bar' in the "
615- <> " current namespace (excluding those under 'lib')."
616- ),
617- ( " find.all foo" ,
618- " lists all definitions with a name similar to 'foo' in the current "
619- <> " namespace (including one level of 'lib')."
620- ),
621- ( " find.global foo" ,
622- " lists all definitions with a name similar to 'foo' in any namespace"
623- )
624- ]
625- )
661+ findHelp
626662 (pure . Input. FindI False fscope)
627663
628664findShallow :: InputPattern
@@ -656,7 +692,7 @@ findVerbose =
656692 ( " `find.verbose` searches for definitions like `find`, but includes hashes "
657693 <> " and aliases in the results."
658694 )
659- (pure . Input. FindI True Input. FindLocal )
695+ (pure . Input. FindI True ( Input. FindLocal Path. empty) )
660696
661697findVerboseAll :: InputPattern
662698findVerboseAll =
@@ -668,7 +704,7 @@ findVerboseAll =
668704 ( " `find.all.verbose` searches for definitions like `find.all`, but includes hashes "
669705 <> " and aliases in the results."
670706 )
671- (pure . Input. FindI True Input. FindLocalAndDeps )
707+ (pure . Input. FindI True ( Input. FindLocalAndDeps Path. empty) )
672708
673709findPatch :: InputPattern
674710findPatch =
@@ -968,11 +1004,11 @@ aliasMany =
9681004up :: InputPattern
9691005up =
9701006 InputPattern
971- " up"
1007+ " deprecated. up"
9721008 []
973- I. Visible
1009+ I. Hidden
9741010 []
975- (P. wrapColumn2 [(makeExample up [] , " move current path up one level" )])
1011+ (P. wrapColumn2 [(makeExample up [] , " move current path up one level (deprecated) " )])
9761012 ( \ case
9771013 [] -> Right Input. UpI
9781014 _ -> Left (I. help up)
@@ -981,12 +1017,12 @@ up =
9811017cd :: InputPattern
9821018cd =
9831019 InputPattern
984- " namespace "
985- [" cd " , " j " ]
1020+ " deprecated.cd "
1021+ [" deprecated.namespace " ]
9861022 I. Visible
9871023 [(" namespace" , Required , namespaceArg)]
9881024 ( P. lines
989- [ " Moves your perspective to a different namespace." ,
1025+ [ " Moves your perspective to a different namespace. Deprecated for now because too many important things depend on your perspective selection. " ,
9901026 " " ,
9911027 P. wrapColumn2
9921028 [ ( makeExample cd [" foo.bar" ],
@@ -1020,7 +1056,7 @@ back =
10201056 []
10211057 ( P. wrapColumn2
10221058 [ ( makeExample back [] ,
1023- " undoes the last" <> makeExample' cd <> " command."
1059+ " undoes the last" <> makeExample' projectSwitch <> " command."
10241060 )
10251061 ]
10261062 )
@@ -1233,15 +1269,18 @@ resetRoot =
12331269 InputPattern
12341270 " reset-root"
12351271 []
1236- I. Visible
1272+ I. Hidden
12371273 [(" namespace or hash to reset to" , Required , namespaceArg)]
1238- ( P. wrapColumn2
1239- [ ( makeExample resetRoot [" .foo" ],
1240- " Reset the root namespace (along with its history) to that of the `.foo` namespace."
1241- ),
1242- ( makeExample resetRoot [" #9dndk3kbsk13nbpeu" ],
1243- " Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`."
1244- )
1274+ ( P. lines
1275+ [ " Deprecated because it's incompatible with projects. ⚠️ Warning, this command can cause codebase corruption." ,
1276+ P. wrapColumn2
1277+ [ ( makeExample resetRoot [" .foo" ],
1278+ " Reset the root namespace (along with its history) to that of the `.foo` namespace. Deprecated"
1279+ ),
1280+ ( makeExample resetRoot [" #9dndk3kbsk13nbpeu" ],
1281+ " Reset the root namespace (along with its history) to that of the namespace with hash `#9dndk3kbsk13nbpeu`."
1282+ )
1283+ ]
12451284 ]
12461285 )
12471286 \ case
@@ -2982,7 +3021,9 @@ validInputs =
29823021 editNamespace,
29833022 execute,
29843023 find,
3024+ findIn,
29853025 findAll,
3026+ findInAll,
29863027 findGlobal,
29873028 findPatch,
29883029 findShallow,
0 commit comments